Part Number Hot Search : 
HEF40 TIC106C LCC32AG NE57810 7C1327 00100 5KP85 LA4192
Product Description
Full Text Search
 

To Download P89V51RD2BN Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  p89v51rd2 8-bit 80c51 5 v low power 64 kb flash microcontroller with 1 kb ram rev. 01 01 march 2004 product data 1. general description the p89v51rd2 is an 80c51 microcontroller with 64 kb flash and 1024 bytes of data ram. a key feature of the p89v51rd2 is its x2 mode option. the design engineer can choose to run the application with the conventional 80c51 clock rate (12 clocks per machine cycle) or select the x2 mode (6 clocks per machine cycle) to achieve twice the throughput at the same clock frequency. another way to bene?t from this feature is to keep the same performance by reducing the clock frequency by half, thus dramatically reducing the emi. the flash program memory supports both parallel programming and in serial in-system programming (isp). parallel programming mode offers gang-programming at high speed, reducing programming costs and time to market. isp allows a device to be reprogrammed in the end product under software control. the capability to ?eld/update the application ?rmware makes a wide range of applications possible. the p89v51rd2 is also in-application programmable (iap), allowing the flash program memory to be recon?gured even while the application is running. 2. features n 80c51 central processing unit n 5 v operating voltage from 0 to 40 mhz n 64 kb of on-chip flash program memory with isp (in-system programming) and iap (in-application programming) n supports 12-clock (default) or 6-clock mode selection via software or isp n spi (serial peripheral interface) and enhanced uart n pca (programmable counter array) with pwm and capture/compare functions n four 8-bit i/o ports with three high-current port 1 pins (16 ma each) n three 16-bit timers/counters n programmable watchdog timer (wdt) n eight interrupt sources with four priority levels n second dptr register n low emi mode (ale inhibit) n ttl- and cmos-compatible logic levels
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 2 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. n brown-out detection n low power modes u power-down mode with external interrupt wake-up u idle mode n pdip40, plcc44 and tqfp44 packages 3. ordering information 3.1 ordering options table 1: ordering information type number package version name description p89v51rd2fa plcc44 plastic leaded chip carrier; 44 leads sot187-2 p89v51rd2fbc tqfp44 plastic thin quad ?at package; 44 leads sot376-1 P89V51RD2BN pdip40 plastic dual in-line package; 40 leads sot129-1 table 2: ordering options type number temperature range frequency p89v51rd2fa - 40 cto+85 c 0 to 40 mhz p89v51rd2fbc - 40 cto+85 c P89V51RD2BN 0 cto+70 c
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 3 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 4. block diagram fig 1. p89v51rd2 block diagram. high performance 80c51 cpu 64 kb code flash 1 kb data ram port 3 oscillator internal bus crystal or resonator 002aaa506 uart spi timer 2 pca programmable counter array timer 0 timer 1 watchdog timer port 2 port 1 port 0
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 4 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 5. pinning information 5.1 pinning fig 2. plcc44 pin con?guration. p89v51rd2fa 002aaa810 7 8 9 10 11 12 13 14 15 16 17 39 38 37 36 35 34 33 32 31 30 29 18 19 20 21 22 23 24 25 26 27 28 6 5 4 3 2 1 44 43 42 41 40 p1.4/ss/cex1 p1.3/cex0 p1.2/eci p1.1/t2ex p1.0/t2 nc v cc p0.0/ad0 p0.1/ad1 p0.2/ad2 p0.3/ad3 wr/p3.6 rd/p3.7 xtal2 xtal1 v ss nc a8/p2.0 a9/p2.1 a10/p2.2 a11/p2.3 a12/p2.4 cex2/mosi/p1.5 cex3/miso/p1.6 cex4/sck/p1.7 rst rxd/p3.0 nc txd/p3.1 int0/p3.2 int1/p3.3 t0/p3.4 t1/p3.5 p0.4/ad4 p0.5/ad5 p0.6/ad6 p0.7/ad7 ea nc ale/prog psen p2.7/a15 p2.6/a14 p2.5/a13
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 5 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. fig 3. pdip40 pin con?guration. handbook, halfpage P89V51RD2BN 002aaa811 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 t2/p1.0 t2ex/p1.1 eci/p1.2 cex0/p1.3 cex1/ss/p1.4 cex2/mosi/p1.5 cex3/miso/p1.6 cex4/sck/p1.7 rst rxd/p3.0 txd/p3.1 int0/p3.2 int1/p3.3 t0/p3.4 t1/p3.5 wr/p3.6 rd/p3.7 xtal2 xtal1 v ss v dd p0.0/ad0 p0.1/ad1 p0.2/ad2 p0.3/ad3 p0.4/ad4 p0.5/ad5 p0.6/ad6 p0.7/ad7 ea ale/prog psen p2.7/a15 p2.6/a14 p2.5/a13 p2.4/a12 p2.3/a11 p2.2/a10 p2.1/a9 p2.0/a8 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 6 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. fig 4. tqfp44 pin con?guration. p89v51rd2fbc 002aaa812 1 2 3 4 5 6 7 8 9 10 11 33 32 31 30 29 28 27 26 25 24 23 12 13 14 15 16 17 18 19 20 21 22 44 43 42 41 40 39 38 37 36 35 34 p1.4/ss/cex1 p1.3/cex0 p1.2/eci p1.1/t2ex p1.0/t2 nc v dd p0.0/ad0 p0.1/ad1 p0.2/ad2 p0.3/ad3 wr/p3.6 rd/p3.7 xtal2 xtal1 v ss nc a8/p2.0 a9/p2.1 a10/p2.2 a11/p2.3 a12/p2.4 cex2/mosi/p1.5 cex3/miso/p1.6 cex4/sck/p1.7 rst rxd/p3.0 nc txd/p3.1 int0/p3.2 int1/p3.3 t0/p3.4 t1/p3.5 p0.4/ad4 p0.5/ad5 p0.6/ad6 p0.7/ad7 ea nc ale/prog psen p2.7/a15 p2.6/a14 p2.5/a13
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 7 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 5.2 pin description table 3: p89v51rd2 pin description symbol pin type description dip40 tqfp44 plcc44 p0.0 to p0.7 39-32 37-30 43-36 i/o port 0: port 0 is an 8-bit open drain bi-directional i/o port. port 0 pins that have 1s written to them ?oat, and in this state can be used as high-impedance inputs. port 0 is also the multiplexed low-order address and data bus during accesses to external code and data memory. in this application, it uses strong internal pull-ups when transitioning to 1s. port 0 also receives the code bytes during the external host mode programming, and outputs the code bytes during the external host mode veri?cation. external pull-ups are required during program veri?cation or as a general purpose i/o port. p1.0 to p1.7 1-8 40-44, 1-3 2-9 i/o with internal pull-up port 1: port 1 is an 8-bit bi-directional i/o port with internal pull-ups. the port 1 pins are pulled high by the internal pull-ups when 1s are written to them and can be used as inputs in this state. as inputs, port 1 pins that are externally pulled low will source current (i il ) because of the internal pull-ups. p1.5, p1.6, p1.7 have high current drive of 16 ma. port 1 also receives the low-order address bytes during the external host mode programming and veri?cation. p1.0 1 40 2 i/o t2: external count input to timer/counter 2 or clock-out from timer/counter 2 p1.1 2 41 3 i t2ex : timer/counter 2 capture/reload trigger and direction control p1.2 3 42 4 i eci : external clock input. this signal is the external clock input for the pca. p1.3 4 43 5 i/o cex0 : capture/compare external i/o for pca module 0. each capture/compare module connects to a port 1 pin for external i/o. when not used by the pca, this pin can handle standard i/o. p1.4 5 44 6 i/o ss : slave port select input for spi cex1 : capture/compare external i/o for pca module 1 p1.5 6 1 7 i/o mosi : master output slave input for spi cex2 : capture/compare external i/o for pca module 2 p1.6 7 2 8 i/o miso : master input slave output for spi cex3 : capture/compare external i/o for pca module 3 p1.7 8 3 9 i/o sck : master output slave input for spi cex4 : capture/compare external i/o for pca module 4
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 8 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. p2.0 to p2.7 21-28 18-25 24-31 i/o with internal pull-up port 2 : port 2 is an 8-bit bi-directional i/o port with internal pull-ups. port 2 pins are pulled high by the internal pull-ups when 1s are written to them and can be used as inputs in this state. as inputs, port 2 pins that are externally pulled low will source current (i il ) because of the internal pull-ups. port 2 sends the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit address (movx@dptr). in this application, it uses strong internal pull-ups when transitioning to 1s. port 2 also receives some control signals and a partial of high-order address bits during the external host mode programming and veri?cation. p3.0 to p3.7 10-17 5, 7-13 11, 13-19 i/o with internal pull-up port 3 : port 3 is an 8-bit bidirectional i/o port with internal pull-ups. port 3 pins are pulled high by the internal pull-ups when 1s are written to them and can be used as inputs in this state. as inputs, port 3 pins that are externally pulled low will source current (i il ) because of the internal pull-ups. port 3 also receives some control signals and a partial of high-order address bits during the external host mode programming and veri?cation. p3.0 10 5 11 i rxd : serial input port p3.1 11 7 13 o txd : serial output port p3.2 12 8 14 i int0 : external interrupt 0 input p3.3 13 9 15 i int1 : external interrupt 1 input p3.4 14 10 16 i t0 : external count input to timer/counter 0 p3.5 15 11 17 i t1 : external count input to timer/counter 1 p3.6 16 12 18 o wr : external data memory write strobe p3.7 17 13 19 o rd : external data memory read strobe psen 29 26 32 i/o program store enable : psen is the read strobe for external program memory. when the device is executing from internal program memory, psen is inactive (high). when the device is executing code from external program memory, psen is activated twice each machine cycle, except that two psen activations are skipped during each access to external data memory. a forced high-to-low input transition on the psen pin while the rst input is continually held high for more than 10 machine cycles will cause the device to enter external host mode programming. rst 9 4 10 i reset : while the oscillator is running, a high logic state on this pin for two machine cycles will reset the device. if the psen pin is driven by a high-to-low input transition while the rst input pin is held high, the device will enter the external host mode, otherwise the device will enter the normal operation mode. table 3: p89v51rd2 pin description continued symbol pin type description dip40 tqfp44 plcc44
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 9 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. [1] ale loading issue: when ale pin experiences higher loading (>30 pf) during the reset, the microcontroller may accidentally enter into modes other than normal working mode. the solution is to add a pull-up resistor of 3 k w to 50 k w to v dd , e.g., for ale pin. [2] for 6-clock mode, ale is emitted at 1 3 of crystal frequency. ea 31 29 35 i external access enable : ea must be connected to v ss in order to enable the device to fetch code from the external program memory. ea must be strapped to v dd for internal program execution. however, security lock level 4 will disable ea, and program execution is only possible from internal program memory. the ea pin can tolerate a high voltage of 12 v. ale/ pr og 30 27 33 i/o address latch enable: ale is the output signal for latching the low byte of the address during an access to external memory. this pin is also the programming pulse input ( pr og) for ?ash programming. normally the ale [1] is emitted at a constant rate of 1 6 the crystal frequency [2] and can be used for external timing and clocking. one ale pulse is skipped during each access to external data memory. however, if ao is set to 1, ale is disabled. nc - 6, 17, 28, 39 1, 12, 23, 34 i/o no connect xtal1 19 15 21 i crystal 1 : input to the inverting oscillator ampli?er and input to the internal clock generator circuits. xtal2 18 14 20 o crystal 2: output from the inverting oscillator ampli?er. v dd 40 38 44 i power supply v ss 20 16 22 i ground table 3: p89v51rd2 pin description continued symbol pin type description dip40 tqfp44 plcc44
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 10 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 6. special function registers remark: special function registers (sfrs) accesses are restricted in the following ways: ? user must not attempt to access any sfr locations not de?ned. ? accesses to any de?ned sfr locations must be strictly for the functions for the sfrs. ? sfr bits labeled -, 0 or 1 can only be written and read as follows: C - unless otherwise speci?ed, must be written with 0, but can return any value when read (even if it was written with 0). it is a reserved bit and may be used in future derivatives. C 0 must be written with 0, and will return a 0 when read. C 1 must be written with 1, and will return a 1 when read.
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. product data rev. 01 01 march 2004 11 of 75 table 4: special function registers * indicates sfrs that are bit addressable. name description sfr addr. bit functions and addresses msb lsb bit address e7 e6 e5 e4 e3 e2 e1 e0 acc* accumulator e0h auxr auxiliary function register 8eh ------ extram ao auxr1 auxiliary function register 1 a2h - - - gf2 0 - dps bit address f7 f6 f5 f4 f3 f2 f1 f0 b* b register f0h ccap0h module 0 capture high fah ccap1h module 1 capture high fbh ccap2h module 2 capture high fch ccap3h module 3 capture high fdh ccap4h module 4 capture high feh ccap0l module 0 capture low eah ccap1l module 1 capture low ebh ccap2l module 2 capture low ech ccap3l module 3 capture low edh ccap4l module 4 capture low eeh ccapm0 module 0 mode dah - ecom_0 capp_0 capn_0 mat_0 tog_0 pwm_0 eccf_0 ccapm1 module 1 mode dbh - ecom_1 capp_1 capn_1 mat_1 tog_1 pwm_1 eccf_1 ccapm2 module 2 mode dch - ecom_2 capp_2 capn_2 mat_2 tog_2 pwm_2 eccf_2 ccapm3 module 3 mode ddh - ecom_3 capp_3 capn_3 mat_3 tog_3 pwm_3 eccf_3 ccapm4 module 4 mode deh - ecom_4 capp_4 capn_4 mat_4 tog_4 pwm_4 eccf_4 bit address df de dd dc db da d9 d8 ccon* pca counter control d8h cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ch pca counter high f9h cl pca counter low e9h cmod pca counter mode d9h cidl wdte - - - cps1 cps0 ecf dptr data pointer (2 bytes) dph data pointer high 83h dpl data pointer low 82h
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. product data rev. 01 01 march 2004 12 of 75 fst flash status register b6 - sb - - edc - - - bit address af ae ad ac ab aa a9 a8 ien0* interrupt enable 0 a8h ea ec et2 es0 et1 ex1 et0 ex0 bit address ef ee ed ec eb ea e9 e8 ien1* interrupt enable 1 e8h ----ebo bit address bf be bd bc bb ba b9 b8 ip0* interrupt priority b8h - ppc pt2 ps pt1 px1 pt0 px0 ip0h interrupt priority 0 high b7h - ppch pt2h psh pt1h px1h pt0h px0h bit address ff fe fd fc fb fa f9 f8 ip1* interrupt priority 1 f8h ----pbo ip1h interrupt priority 1 high f7h ---- pboh fcf b1h------- bsel bit address 87 86 85 84 83 82 81 80 p0* port 0 80h ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 bit address 97 96 95 94 93 92 91 90 p1* port 1 90h cex4/ spiclk cex3/ miso cex2/ mosi cex1/ ss cex0 eci t2ex t2 bit address a7 a6 a5 a4 a3 a2 a1 a0 p2* port 2 a0h a15 a14 a13 a12 a11 a10 a9 a8 bit address b7 b6 b5 b4 b3 b2 b1 b0 p3* port 3 b0h rd wr t1 t0 int1 int0 txd rxd pcon power control register 87h smod1 smod0 bof pof gf1 gf0 pd idl bit address d7 d6 d5 d4 d3 d2 d1 d0 psw* program status word d0h cy ac f0 rs1 rs0 ov f1 p rcap2h timer2 capture high cbh rcap2l timer2 capture low cah bit address 9f 9e 9d 9c 9b 9a 99 98 scon* serial port control 98h sm0/fe_ sm1 sm2 ren tb8 rb8 ti ri sbuf serial port data buffer register 99h table 4: special function registers continued * indicates sfrs that are bit addressable. name description sfr addr. bit functions and addresses msb lsb
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. product data rev. 01 01 march 2004 13 of 75 [1] unimplemented bits in sfrs (labeled -) are xs (unknown) at all times. unless otherwise speci?ed, 1s should not be writt en to these bits since they may be used for other purposes in future derivatives. the reset values shown for these bits are 0s although they are unknown when read. saddr serial port address register a9h saden serial port address enable b9h bit address 87 [1] 86 [1] 85 [1] 84 [1] 83 [1] 82 [1] 81 [1] 80 [1] spctl spi control register d5h spie spen dord mstr cpol cpha spr1 spr0 spcfg spi con?guration register aah spif spwcol - - ---- spdat spi data 86h sp stack pointer 81h bit address 8f 8e 8d 8c 8b 8a 89 88 tcon* timer control register 88h tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 bit address cf ce cd cc cb ca c9 c8 t2con* timer2 control register c8h tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl2 t2mod timer2 mode control c9h - - ent2 t2oe dcen th0 timer 0 high 8ch th1 timer 1 high 8dh th2 timer 2 high cdh tl0 timer 0 low 8ah tl1 timer 1 low 8bh tl2 timer 2 low cch tmod timer 0 and 1 mode 89h gate c/t m1 m0 gate c/t m1 m0 wdtc watchdog timer control c0h - - - wdout wdre wdts wdt swdt wdtd watchdog timer data/reload 85h table 4: special function registers continued * indicates sfrs that are bit addressable. name description sfr addr. bit functions and addresses msb lsb
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 14 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7. functional description 7.1 memory organization the device has separate address spaces for program and data memory. 7.1.1 flash program memory there are two internal ?ash memory blocks in the device. block 0 has 64 kbytes and contains the users code. block 1 contains the philips-provided isp/iap routines and may be enabled such that it overlays the ?rst 8 kbytes of the user code memory. the 64 kb block 0 is organized as 512 sectors, each sector consists of 128 bytes. access to the iap routines may be enabled by clearing the bsel bit in the fcf register. however, caution must be taken when dynamically changing the bsel bit. since this will cause different physical memory to be mapped to the logical program address space, the user must avoid clearing the bsel bit when executing user code within the address range 0000h to 1fffh. 7.1.2 data ram memory the data ram has 1024 bytes of internal memory. the device can also address up to 64 kb for external data memory. 7.1.3 expanded data ram addressing the p89v51rd2 has 1 kb of ram. see figure 5 internal and external data memory structure. on page 17 . the device has four sections of internal data memory: 1. the lower 128 bytes of ram (00h to 7fh) are directly and indirectly addressable. 2. the higher 128 bytes of ram (80h to ffh) are indirectly addressable. 3. the special function registers (80h to ffh) are directly addressable only. 4. the expanded ram of 768 bytes (00h to 2ffh) is indirectly addressable by the move external instruction (movx) and clearing the extram bit. (see auxiliary register (auxr) in section 6 special function registers on page 10 ) since the upper 128 bytes occupy the same addresses as the sfrs, the ram must be accessed indirectly. the ram and sfrs space are physically separate even though they have the same addresses. table 5: auxr - auxiliary register (address 8eh) bit allocation not bit addressable; reset value 00h bit 7 6 5 4 3 2 1 0 symbol ------ extram ao
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 15 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. when instructions access addresses in the upper 128 bytes (above 7fh), the mcu determines whether to access the sfrs or ram by the type of instruction given. if it is indirect, then ram is accessed. if it is direct, then an sfr is accessed. see the examples below. indirect access: mov@r0, #data; r0 contains 90h register r0 points to 90h which is located in the upper address range. data in #data is written to ram location 90h rather than port 1. direct access: mov90h, #data; write data to p1 data in #data is written to port 1. instructions that write directly to the address write to the sfrs. to access the expanded ram, the extram bit must be cleared and movx instructions must be used. the extra 768 bytes of memory is physically located on the chip and logically occupies the ?rst 768 bytes of external memory (addresses 000h to 2ffh). when extram = 0, the expanded ram is indirectly addressed using the movx instruction in combination with any of the registers r0, r1 of the selected bank or dptr. accessing the expanded ram does not affect ports p0, p3.6 ( wr), p3.7 ( rd), or p2. with extram = 0, the expanded ram can be accessed as in the following example. expanded ram access (indirect addressing only): movx@dptr, a dptr contains 0a0h dptr points to 0a0h and data in a is written to address 0a0h of the expanded ram rather than external memory. access to external memory higher than 2ffh using the movx instruction will access external memory (0300h to ffffh) and will perform in the same way as the standard 8051, with p0 and p2 as data/address bus, and p3.6 and p3.7 as write and read timing signals. table 6: auxr - auxiliary register (address 8eh) bit description bit symbol description 7 to 2 - reserved for future use. should be set to 0 by user programs. 1 extram internal/external ram access using movx @ri/@dptr. when 0, core attempts to access internal xram with address speci?ed in movx instruction. if address supplied with this instruction exceeds on-chip available xram, off-chip xram is going to be selected and accessed. when 1, every movx @ri/@dptr instruction targets external data memory by default. 0 ao ale off: disables/enables ale. ao = 0 results in ale emitted at a constant rate of 1 2 the oscillator frequency. in case of ao = 1, ale is active only during a movx or movc.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 16 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. when extram = 1 , movx @ri and movx @dptr will be similar to the standard 8051. using movx @ri provides an 8-bit address with multiplexed data on port 0. other output port pins can be used to output higher order address bits. this provides external paging capabilities. using movx @dptr generates a 16-bit address. this allows external addressing up the 64 kb. port 2 provides the high-order eight address bits (dph), and port 0 multiplexes the low order eight address bits (dpl) with data. both movx @ri and movx @dptr generates the necessary read and write signals (p3.6 - wr and p3.7 - rd) for external memory use. ta b l e 7 shows external data memory rd, wr operation with extram bit. the stack pointer (sp) can be located anywhere within the 256 bytes of internal ram (lower 128 bytes and upper 128 bytes). the stack pointer may not be located in any part of the expanded ram. [1] access limited to eram address within 0 to 0ffh; cannot access 100h to 02ffh. table 7: external data memory rd, wr with extram bit auxr movx @dptr, a or movx a, @dptr movx @ri, a or movx a, @ri addr < 0300h addr 3 0300h addr = any extram = 0 rd/ wr not asserted rd/ wr asserted rd/ wr not asserted extram = 1 rd/ wr asserted rd/ wr asserted rd/ wr asserted
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 17 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.1.4 dual data pointers the device has two 16-bit data pointers. the dptr select (dps) bit in auxr1 determines which of the two data pointers is accessed. when dps = 0, dptr0 is selected; when dps = 1 , dptr1 is selected. quickly switching between the two data pointers can be accomplished by a single inc instruction on auxr1 (see figure 6 ). fig 5. internal and external data memory structure. 000h 2ffh 00h ffh upper 128 bytes internal ram lower 128 bytes internal ram (indirect & direct addressing) (indirect addressing) (direct addressing) special function registers (sfrs) 80h ffh ffffh 000h external data memory external data memory 2ffh 0000h extram = 0 extram = 1 expanded ram 0300h (indirect addressing) (indirect addressing) (indirect addressing) ffffh 80h 7fh 002aaa517 expanded ram 768 bytes fig 6. dual data pointer organization. dpl 82h dps = 0 ? dptr0 dps = 1 ? dptr1 external data memory dps 002aaa518 dph 83h dptr0 dptr1 auxr1 / bit0
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 18 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.2 flash memory in-application programming 7.2.1 flash organization the p89v51rd2 program memory consists of a 64 kb block. an in-system programming (isp) capability, in a second 8 kb block, is provided to allow the user code to be programmed in-circuit through the serial port. there are three methods of erasing or programming of the flash memory that may be used. first, the flash may be programmed or erased in the end-user application by calling low-level routines through a common entry point (iap). second, the on-chip isp boot loader may be invoked. this isp boot loader will, in turn, call low-level routines through the same common entry point that can be used by the end-user application. third, the flash may be programmed or erased using the parallel method by using a commercially available eprom programmer which supports this device. 7.2.2 boot block when the microcontroller programs its own flash memory, all of the low level details are handled by code that is contained in a boot block that is separate from the user flash memory. a user program calls the common entry point in the boot block with appropriate parameters to accomplish the desired operation. boot block operations include erase user code, program user code, program security bits, etc. a chip-erase operation can be performed using a commercially available parallel programer. this operation will erase the contents of this boot block and it will be necessary for the user to reprogram this boot block (block 1) with the philips-provided isp/iap code in order to use the isp or iap capabilities of this device. contact http://www.semiconductors.philips.com to obtain the hex ?le for this device. questions may be directed to micro.support@philips.com . table 8: auxr1 - auxiliary register 1 (address a2h) bit allocation not bit addressable; reset value 00h bit 7 6 5 4 3 2 1 0 symbol - - - - gf2 0 - dps table 9: auxr1 - auxiliary register 1 (address a2h) bit description bit symbol description 7 to 4 - reserved for future use. should be set to 0 by user programs. 3 gf2 general purpose user-de?ned ?ag. 2 0 this bit contains a hard-wired 0. allows toggling of the dps bit by incrementing auxr1, without interfering with other bits in the register. 1 - reserved for future use. should be set to 0 by user programs. 0 dps data pointer select. chooses one of two data pointers for use by the program. see text for details.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 19 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.2.3 power-on reset code execution following reset, the p89v51rd2 will either enter the softice mode (if previously enabled via isp command) or attempt to autobaud to the isp boot loader. if this autobaud is not successful within about 400 ms, the device will begin execution of the user code. 7.2.4 in-system programming (isp) in-system programming is performed without removing the microcontroller from the system. the in-system programming facility consists of a series of internal hardware resources coupled with internal ?rmware to facilitate remote programming of the p89v51rd2 through the serial port. this ?rmware is provided by philips and embedded within each p89v51rd2 device. the philips in-system programming facility has made in-circuit programming in an embedded application possible with a minimum of additional expense in components and circuit board area. the isp function uses ?ve pins (v dd ,v ss , txd, rxd, and rst). only a small connector needs to be available to interface your application to an external circuit in order to use this feature. 7.2.5 using the in-system programming the isp feature allows for a wide range of baud rates to be used in your application, independent of the oscillator frequency. it is also adaptable to a wide range of oscillator frequencies. this is accomplished by measuring the bit-time of a single bit in a received character. this information is then used to program the baud rate in terms of timer counts based on the oscillator frequency. the isp feature requires that an initial character (an uppercase u) be sent to the p89v51rd2 to establish the baud rate. the isp ?rmware provides auto-echo of received characters. once baud rate initialization has been performed, the isp ?rmware will only accept intel hex-type records. intel hex records consist of ascii characters used to represent hexadecimal values and are summarized below: :nnaaaarrdd..ddcc in the intel hex record, the nn represents the number of data bytes in the record. the p89v51rd2 will accept up to 32 data bytes. the aaaa string represents the address of the ?rst byte in the record. if there are zero bytes in the record, this ?eld is often set to 0000. the rr string indicates the record type. a record type of 00 is a data record. a record type of 01 indicates the end-of-?le mark. in this application, additional record types will be added to indicate either commands or data for the isp facility. the maximum number of data bytes in a record is limited to 32 (decimal). isp commands are summarized in ta b l e 1 0 . as a record is received by the p89v51rd2, the information in the record is stored internally and a checksum calculation is performed. the operation indicated by the record type is not performed until the entire record has been received. should an error occur in the checksum, the p89v51rd2 will send an x out the serial port indicating a checksum error. if the checksum calculation is found to match the checksum in the record, then the command will be executed. in most cases, successful reception of the record will be indicated by transmitting a . character out the serial port.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 20 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. table 10: in-system programming (isp) hex record formats record type command/data function 00 program user code memory :nnaaaa00dd..ddcc where: nn = number of bytes to program aaaa = address dd..dd = data bytes cc = checksum example: :100000000102030405006070809cc 01 end of file (eof), no operation :xxxxxx01cc where: xxxxxx = required ?eld but value is a dont care cc = checksum example: :00000001ff 02 set softice mode following the next reset the device will enter the softice mode. will erase user code memory, erase device serial number. :00000002cc where: xxxxxx = required ?eld but value is a dont care cc = checksum example: :00000002fe
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 21 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 03 miscellaneous write functions :nnxxxx03ffssddcc where: nn = number of bytes in the record xxxx = required ?eld but value is a dont care ff = subfunction code ss = selection code dd = data (if needed) cc = checksum subfunction code = 01 (erase block 0) ff = 01 subfunction code = 05 (program security bit, double clock) ff = 05 ss = 01 program security bit ss = 05 program double clock bit subfunction code = 08 (erase sector, 128 bytes) ff = 08 ss = high byte of sector address (a15:8) dd = low byte of sector address (a7, a6:0 = 0) example: :0300000308e000f2 (erase sector at e000h) 04 display device data or blank check :05xxxx04sssseeeeffcc where 05 = number of bytes in the record xxxx = required ?eld but value is a dont care 04 = function code for display or blank check ssss = starting address, msb ?rst eeee = ending address, msb ?rst ff = subfunction 00 = display data 01 = blank check cc = checksum subfunction codes: example: :0500000400001fff00d9 (display from 0000h to 1fffh) table 10: in-system programming (isp) hex record formats continued record type command/data function
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 22 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 05 miscellaneous read functions :02xxxx05ffsscc where: 02 = number of bytes in the record xxxx = required ?eld but value is a dont care 05 = function code for misc read ffss = subfunction and selection code 0000 = read manufacturer id 0001 = read device id 1 0002 = read isp/iap version 0700 = read security bit (00000 sb 0 double clock) cc = checksum example: :020000050000f9 (display manufacturer id) 06 direct load of baud rate :02xxxx06hhllcc where: 02 = number of bytes in the record xxxx = required ?eld but value is a dont care hh = high byte of timer ll = low byte of timer cc = checksum example: :02000007ffffcc (load t2 = 7fff) 07 reset serial number :xxxxxx07cc where: xxxxxx = required ?eld but value is a dont care 07 = reset serial number function cc = checksum example: :00000001ff table 10: in-system programming (isp) hex record formats continued record type command/data function
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 23 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.2.6 using the serial number this device has the option of storing a 31-byte serial number along with the length of the serial number (for a total of 32 bytes) in a non-volatile memory space. when isp mode is entered, the serial number length is evaluated to determine if the serial number is in use. if the length of the serial number is programmed to either 00h or ffh, the serial number is considered not in use. if the serial number is in use, reading, programming, or erasing of the user code memory or the serial number is blocked until the user transmits a verify serial number record containing a serial number and length that matches the serial number and length previously stored in the device. the user can reset the serial number to all zeros and set the length to zero by sending the reset serial number' record. in addition, the reset serial number record will also erase all user code. 7.2.7 in-application programming method several in-application programming (iap) calls are available for use by an application program to permit selective erasing, reading and programming of flash sectors, pages, security bit, con?guration bytes, and device id. all calls are made through a 08 verify serial number :nnxxxx08ss..sscc where: xxxxxx = required ?eld but value is a dont care 08 = verify serial number function ss..ss = serial number contents cc = checksum example: :03000008010203ef (verify s/n = 010203) 09 write serial number :nnxxxx09ss..sscc where: xxxxxx = required ?eld but value is a dont care 09 = write serial number function ss..ss = serial number contents cc = checksum example: :03000009010203ee (write s/n = 010203) 0a display serial number :xxxxxx0acc where: xxxxxx = required ?eld but value is a dont care 0a = display serial number function cc = checksum example: :0000000af6 table 10: in-system programming (isp) hex record formats continued record type command/data function
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 24 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. common interface, pgm_mtp. the programming functions are selected by setting up the microcontrollers registers before making a call to pgm_mtp at 1ff0h. the iap calls are shown in ta b l e 1 1 table 11: iap function calls iap function iap call parameters read id input parameters: r1 = 00h dph = 00h dpl = 00h = mfgr id dpl = 01h = device id 1 dpl = 02h = isp version number dpl = 03h = iap version number return parameter(s): acc = requested parameter erase block 0 input parameters: r1 = 01h return parameter(s): acc = 00 = pass acc=!00=fail program user code input parameters: r1 = 02h dph = memory address msb dpl = memory address lsb acc = byte to program return parameter(s): acc = 00 = pass acc=!00=fail read user code input parameters: r1 = 03h dph = memory address msb dpl = memory address lsb return parameter(s): acc = device data program security bit, double clock input parameters: r1 = 05h dpl = 01h = security bit dpl = 05h = double clock return parameter(s): acc = 00 = pass acc=!00=fail read security bit, double clock input parameters: acc = 07h return parameter(s): acc = 000 s/n-match 0 sb 0 dbl_clk
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 25 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.3 timers/counters 0 and 1 the two 16-bit timer/counter registers: timer 0 and timer 1 can be con?gured to operate either as timers or event counters (see ta b l e 1 2 and ta b l e 1 3 ). in the timer function, the register is incremented every machine cycle. thus, one can think of it as counting machine cycles. since a machine cycle consists of six oscillator periods, the count rate is 1 6 of the oscillator frequency. in the counter function, the register is incremented in response to a 1-to-0 transition at its corresponding external input pin, t0 or t1. in this function, the external input is sampled once every machine cycle. when the samples show a high in one cycle and a low in the next cycle, the count is incremented. the new count value appears in the register in the machine cycle following the one in which the transition was detected. since it takes two machine cycles (12 oscillator periods) for 1-to-0 transition to be recognized, the maximum count rate is 1 12 of the oscillator frequency. there are no restrictions on the duty cycle of the external input signal, but to ensure that a given level is sampled at least once before it changes, it should be held for at least one full machine cycle. in addition to the timer or counter selection, timer 0 and timer 1 have four operating modes from which to select. the timer or counter function is selected by control bits c/t in the special function register tmod. these two timer/counters have four operating modes, which are selected by bit-pairs (m1, m0) in tmod. modes 0, 1, and 2 are the same for both timers/counters. mode 3 is different. the four operating modes are described in the following text. table 12: tmod - timer/counter mode control register (address 89h) bit allocation not bit addressable; reset value: 00000000b; reset source(s): any source bit 7 6 5 4 3 2 1 0 symbol t1gate t1c/ t t1m1 t1m0 t0gate t0c/ t t0m1 t0m0 table 13: tmod - timer/counter mode control register (address 89h) bit description bit symbol description t1/t0 bits controlling timer1/timer0 gate gating control when set. timer/counter x is enabled only while intx pin is high and trx control pin is set. when cleared, timer x is enabled whenever trx control bit is set. c/ t gating timer or counter selector cleared for timer operation (input from internal system clock.) set for counter operation (input from tx input pin).
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 26 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.3.1 mode 0 putting either timer into mode 0 makes it look like an 8048 timer, which is an 8-bit counter with a ?xed divide-by-32 prescaler. figure 7 shows mode 0 operation. table 14: tmod - timer/counter mode control register (address 89h) m1/m0 operating mode m1 m0 operating mode 0 0 0 8048 timer tlx serves as 5-bit prescaler 0 1 1 16-bit timer/counter thx and tlx' are cascaded; there is no prescaler. 1 0 2 8-bit auto-reload timer/counter thx holds a value which is to be reloaded into tlx each time it over?ows. 1 1 3 (timer 0) tl0 is an 8-bit timer/counter controlled by the standard timer 0 control bits. th0 is an 8-bit timer only controlled by timer 1 control bits. 1 1 3 (timer 1) timer/counter 1 stopped. table 15: tcon - timer/counter control register (address 88h) bit allocation bit addressable; reset value: 00000000b; reset source(s): any reset bit 7 6 5 4 3 2 1 0 symbol tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 table 16: tcon - timer/counter control register (address 88h) bit description bit symbol description 7 tf1 timer 1 over?ow ?ag. set by hardware on timer/counter over?ow. cleared by hardware when the processor vectors to timer 1 interrupt routine, or by software. 6 tr1 timer 1 run control bit. set/cleared by software to turn timer/counter 1 on/off. 5 tf0 timer 0 over?ow ?ag. set by hardware on timer/counter over?ow. cleared by hardware when the processor vectors to timer 0 interrupt routine, or by software. 4 tr0 timer 0 run control bit. set/cleared by software to turn timer/counter 0 on/off. 3 ie1 interrupt 1 edge ?ag. set by hardware when external interrupt 1 edge/low level is detected. cleared by hardware when the interrupt is processed, or by software. 2 it1 interrupt 1 type control bit. set/cleared by software to specify falling edge/low level that triggers external interrupt 1. 1 ie0 interrupt 0 edge ?ag. set by hardware when external interrupt 0 edge/low level is detected. cleared by hardware when the interrupt is processed, or by software. 0 it0 interrupt 0 type control bit. set/cleared by software to specify falling edge/low level that triggers external interrupt 0.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 27 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. in this mode, the timer register is con?gured as a 13-bit register. as the count rolls over from all 1s to all 0s, it sets the timer interrupt ?ag tfn. the count input is enabled to the timer when trn = 1 and either gate = 0 or intn = 1 . (setting gate = 1 allows the timer to be controlled by external input intn, to facilitate pulse width measurements). trn is a control bit in the special function register tcon ( figure 6 ). the gate bit is in the tmod register. the 13-bit register consists of all 8 bits of thn and the lower 5 bits of tln. the upper 3 bits of tln are indeterminate and should be ignored. setting the run ?ag (trn) does not clear the registers. mode 0 operation is the same for timer 0 and timer 1 (see figure 7 ). there are two different gate bits, one for timer 1 (tmod.7) and one for timer 0 (tmod.3). 7.3.2 mode 1 mode 1 is the same as mode 0, except that all 16 bits of the timer register (thn and tln) are used. see figure 8 . 7.3.3 mode 2 mode 2 con?gures the timer register as an 8-bit counter (tln) with automatic reload, as shown in figure 9 . over?ow from tln not only sets tfn, but also reloads tln with the contents of thn, which must be preset by software. the reload leaves thn unchanged. mode 2 operation is the same for timer 0 and timer 1. fig 7. timer/counter 0 or 1 in mode 0 (13-bit counter). 002aaa519 osc/6 tn pin trn tngate intn pin c/t = 0 c/t = 1 tln (5-bits) thn (8-bits) tfn control overflow interrupt fig 8. timer/counter 0 or 1 in mode 1 (16-bit counter). 002aaa520 osc/6 tn pin trn tngate intn pin c/t = 0 c/t = 1 tln (8-bits) thn (8-bits) tfn control overflow interrupt
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 28 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.3.4 mode 3 when timer 1 is in mode 3 it is stopped (holds its count). the effect is the same as setting tr1 = 0. timer 0 in mode 3 establishes tl0 and th0 as two separate 8-bit counters. the logic for mode 3 and timer 0 is shown in figure 10 . tl0 uses the timer 0 control bits: t0c/ t, t0gate, tr0, int0, and tf0. th0 is locked into a timer function (counting machine cycles) and takes over the use of tr1 and tf1 from timer 1. thus, th0 now controls the timer 1 interrupt. mode 3 is provided for applications that require an extra 8-bit timer. with timer 0 in mode 3, the p89v51rd2 can look like it has an additional timer. note: when timer 0 is in mode 3, timer 1 can be turned on and off by switching it into and out of its own mode 3. it can still be used by the serial port as a baud rate generator, or in any application not requiring an interrupt. 7.4 timer 2 timer 2 is a 16-bit timer/counter which can operate as either an event timer or an event counter, as selected by c/t2 in the special function register t2con. timer 2 has four operating modes: capture, auto-reload (up or down counting), clock-out, and baud rate generator which are selected according to ta b l e 1 7 using t2con ( ta b l e 1 8 and ta b l e 1 9 ) and t2mod ( ta b l e 2 0 and ta b l e 2 1 ). fig 9. timer/counter 0 or 1 in mode 2 (8-bit auto-reload). 002aaa521 osc/6 tn pin trn tngate intn pin c/t = 0 c/t = 1 tln (8-bits) thn (8-bits) tfn control overflow reload interrupt fig 10. timer/counter 0 mode 3 (two 8-bit counters). 002aaa522 osc/6 osc/2 tr1 t0 pin tr0 tngate int0 pin c/t = 0 c/t = 1 tl0 (8-bits) tf0 control overflow interrupt th0 (8-bits) tf1 control overflow interrupt
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 29 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. table 17: timer 2 operating mode rclk+tclk cp/ rl2 tr2 t2oe mode 0010 16-bit auto reload 0110 16-bit capture 0011 programmable clock-out 1 x 1 0 baud rate generator xx0 xoff table 18: t2con - timer/counter 2 control register (address c8h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol tf2 exf2 rclk tclk exen2 tr2 c/ t2 cp/ rl2 table 19: t2con - timer/counter 2 control register (address c8h) bit description bit symbol description 7 tf2 timer 2 over?ow ?ag set by a timer 2 over?ow and must be cleared by software. tf2 will not be set when either rclk or tclk = 1 or when timer 2 is in clock-out mode. 6 exf2 timer 2 external ?ag is set when timer 2 is in capture, reload or baud-rate mode, exen2 = 1 and a negative transition on t2ex occurs. if timer 2 interrupt is enabled exf2 = 1 causes the cpu to vector to the timer 2 interrupt routine. exf2 must be cleared by software. 5 rclk receive clock ?ag. when set, causes the uart to use timer 2 over?ow pulses for its receive clock in modes 1 and 3. rclk = 0 causes timer 1 over?ow to be used for the receive clock. 4 tclk transmit clock ?ag. when set, causes the uart to use timer 2 over?ow pulses for its transmit clock in modes 1 and 3. tclk = 0 causes timer 1 over?ows to be used for the transmit clock. 3 exen2 timer 2 external enable ?ag. when set, allows a capture or reload to occur as a result of a negative transition on t2ex if timer 2 is not being used to clock the serial port. exen2 = 0 causes timer 2 to ignore events at t2ex. 2 tr2 start/stop control for timer 2. a logic 1 enables the timer to run. 1c/ t2 timer or counter select. (timer 2) 0 = internal timer (f osc /6) 1 = external event counter (falling edge triggered; external clocks maximum rate = f osc /12 0 cp/ rl2 capture/reload ?ag. when set, captures will occur on negative transitions at t2ex if exen2 = 1. when cleared, auto-reloads will occur either with timer 2 over?ows or negative transitions at t2ex when exen2 = 1. when either rclk = 1 or tclk = 1, this bit is ignored and the timer is forced to auto-reload on timer 2 over?ow. table 20: t2mod - timer 2 mode control register (address c9h) bit allocation not bit addressable; reset value: xx000000b bit 7 6 5 4 3 2 1 0 symbol - - - - - - t2oe dcen
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 30 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.4.1 capture mode in the capture mode there are two options which are selected by bit exen2 in t2con. if exen2 = 0 timer 2 is a 16-bit timer or counter (as selected by c/ t2 in t2con) which upon over?owing sets bit tf2, the timer 2 over?ow bit. the capture mode is illustrated in figure 11 . this bit can be used to generate an interrupt (by enabling the timer 2 interrupt bit in the ien0 register). if exen2 = 1, timer 2 operates as described above, but with the added feature that a 1- to -0 transition at external input t2ex causes the current value in the timer 2 registers, tl2 and th2, to be captured into registers rcap2l and rcap2h, respectively. in addition, the transition at t2ex causes bit exf2 in t2con to be set, and exf2 like tf2 can generate an interrupt (which vectors to the same location as timer 2 over?ow interrupt). the timer 2 interrupt service routine can interrogate tf2 and exf2 to determine which event caused the interrupt. there is no reload value for tl2 and th2 in this mode. even when a capture event occurs from t2ex, the counter keeps on counting t2 pin transitions or f osc /6 pulses. since once loaded contents of rcap2l and rcap2h registers are not protected, once timer2 interrupt is signalled it has to be serviced before new capture event on t2ex pin occurs. otherwise, the next falling edge on t2ex pin will initiate reload of the current value from tl2 and th2 to rcap2l and rcap2h and consequently corrupt their content related to previously reported interrupt. table 21: t2mod - timer 2 mode control register (address c9h) bit description bit symbol description 7 to 2 - reserved for future use. should be set to 0 by user programs. 1 t2oe timer 2 output enable bit. used in programmable clock-out mode only. 0 dcen down count enable bit. when set, this allows timer 2 to be con?gured as an up/down counter. fig 11. timer 2 in capture mode. 002aaa523 osc ? 6 t2 pin c/t2 = 0 c/t2 = 1 tl2 (8-bits) th2 (8-bits) tf2 control capture tr2 timer 2 interrupt exf2 rcap2l rcap2h control exen2 transition detector t2ex pin
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 31 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.4.2 auto-reload mode (up or down counter) in the 16-bit auto-reload mode, timer 2 can be con?gured as either a timer or counter (via c/ t2 in t2con), then programmed to count up or down. the counting direction is determined by bit dcen (down counter enable) which is located in the t2mod register (see ta b l e 2 0 and ta b l e 2 1 ). when reset is applied, dcen = 0 and timer 2 will default to counting up. if the dcen bit is set, timer 2 can count up or down depending on the value of the t2ex pin. figure 12 shows timer 2 counting up automatically (dcen = 0). in this mode, there are two options selected by bit exen2 in t2con register. if exen2 = 0, then timer 2 counts up to 0ffffh and sets the tf2 (over?ow flag) bit upon over?ow. this causes the timer 2 registers to be reloaded with the 16-bit value in rcap2l and rcap2h. the values in rcap2l and rcap2h are preset by software means. auto reload frequency when timer 2 is counting up can be determined from this formula: (1) where supplyfrequency is either f osc (c/ t2 = 0) or frequency of signal on t2 pin (c/ t2 = 1 ). if exen2 = 1 , a 16-bit reload can be triggered either by an over?ow or by a 1-to-0 transition at input t2ex. this transition also sets the exf2 bit. the timer 2 interrupt, if enabled, can be generated when either tf2 or exf2 is 1 . microcontrollers hardware will need three consecutive machine cycles in order to recognize falling edge on t2ex and set exf2 = 1 : in the ?rst machine cycle pin t2ex has to be sampled as 1; in the second machine cycle it has to be sampled as 0, and in the third machine cycle exf2 will be set to 1 . fig 12. timer 2 in auto-reload mode (dcen = 0) 002aaa524 osc ? 6 t2 pin c/t2 = 0 c/t2 = 1 tl2 (8-bits) th2 (8-bits) tf2 control reload tr2 timer 2 interrupt exf2 rcap2l rcap2h control exen2 transition detector t2ex pin supplyfrequency 65536 rcap2h rcap2l , () e () ------------------------------------------------------------------------------- -
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 32 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. in figure 13 , dcen = 1 and timer 2 is enabled to count up or down. this mode allows pin t2ex to control the direction of count. when a logic 1 is applied at pin t2ex timer 2 will count up. timer 2 will over?ow at 0ffffh and set the tf2 ?ag, which can then generate an interrupt, if the interrupt is enabled. this timer over?ow also causes the 16-bit value in rcap2l and rcap2h to be reloaded into the timer registers tl2 and th2. when a logic 0 is applied at pin t2ex this causes timer 2 to count down. the timer will under?ow when tl2 and th2 become equal to the value stored in rcap2l and rcap2h. timer 2 under?ow sets the tf2 ?ag and causes 0ffffh to be reloaded into the timer registers tl2 and th2. the external ?ag exf2 toggles when timer 2 under?ows or over?ows. this exf2 bit can be used as a 17th bit of resolution if needed. 7.4.3 programmable clock-out a 50% duty cycle clock can be programmed to come out on pin t2 (p1.0). this pin, besides being a regular i/o pin, has two additional functions. it can be programmed: 1. to input the external clock for timer/counter 2, or 2. to output a 50% duty cycle clock ranging from 122 hz to 8 mhz at a 16 mhz operating frequency. to con?gure the timer/counter 2 as a clock generator, bit c/ t2 (in t2con) must be cleared and bit t20e in t2mod must be set. bit tr2 (t2con.2) also must be set to start the timer. the clock-out frequency depends on the oscillator frequency and the reload value of timer 2 capture registers (rcap2h, rcap2l) as shown in equation 2 : fig 13. timer 2 in auto reload mode (dcen = 1). 002aaa525 osc ? 6 t2 pin c/t2 = 0 c/t2 = 1 tl2 (8-bits) th2 (8-bits) tf2 exf2 underflow control tr2 timer 2 interrupt rcap2l rcap2h ffh ffh overflow (down counting reload value) (up counting reload value) count direction 1 = up 0 = down t2ex pin toggle
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 33 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. (2) where (rcap2h,rcap2l) = the content of rcap2h and rcap2l taken as a 16-bit unsigned integer. in the clock-out mode timer 2 roll-overs will not generate an interrupt. this is similar to when it is used as a baud-rate generator. 7.4.4 baud rate generator mode bits tclk and/or rclk in t2con allow the uart) transmit and receive baud rates to be derived from either timer 1 or timer 2 (see section 7.5 uarts on page 35 for details). when tclk = 0, timer 1 is used as the uart transmit baud rate generator. when tclk = 1 , timer 2 is used as the uart transmit baud rate generator. rclk has the same effect for the uart receive baud rate. with these two bits, the serial port can have different receive and transmit baud rates C timer 1 or timer 2. figure 14 shows timer 2 in baud rate generator mode: the baud rate generation mode is like the auto-reload mode, when a rollover in th2 causes the timer 2 registers to be reloaded with the 16-bit value in registers rcap2h and rcap2l, which are preset by software. the baud rates in modes 1 and 3 are determined by timer 2s over?ow rate given below: modes 1 and 3 baud rates = timer 2 over?ow rate/16 the timer can be con?gured for either timer or counter operation. in many applications, it is con?gured for timer' operation (c/ t2 = 0). timer operation is different for timer 2 when it is being used as a baud rate generator. usually, as a timer it would increment every machine cycle (i.e., 1 6 the oscillator frequency). as a baud rate generator, it increments at the oscillator frequency. thus the baud rate formula is as follows: oscillatorfrequency 2 65536 rcap2h rcap2l , () e () ----------------------------------------------------------------------------------------- fig 14. timer 2 in baud rate generator mode. 002aaa526 osc ? 2 t2 pin c/t2 = 0 c/t2 = 1 control tr2 rcap2l rcap2h control exen2 transition detector t2ex pin reload tx/rx baud rate tl2 (8-bits) th2 (8-bits) exf2 timer 2 interrupt
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 34 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. modes 1 and 3 baud rates = (3) where: (rcap2h, rcap2l) = the content of rcap2h and rcap2l taken as a 16-bit unsigned integer. the timer 2 as a baud rate generator mode is valid only if rclk and/or tclk = 1 in t2con register. note that a rollover in th2 does not set tf2, and will not generate an interrupt. thus, the timer 2 interrupt does not have to be disabled when timer 2 is in the baud rate generator mode. also if the exen2 (t2 external enable ?ag) is set, a 1-to-0 transition in t2ex (timer/counter 2 trigger input) will set exf2 (t2 external ?ag) but will not cause a reload from (rcap2h, rcap2l) to (th2,tl2). therefore when timer 2 is in use as a baud rate generator, t2ex can be used as an additional external interrupt, if needed. when timer 2 is in the baud rate generator mode, one should not try to read or write th2 and tl2. under these conditions, a read or write of th2 or tl2 may not be accurate. the rcap2 registers may be read, but should not be written to, because a write might overlap a reload and cause write and/or reload errors. the timer should be turned off (clear tr2) before accessing the timer 2 or rcap2 registers. ta b l e 2 2 shows commonly used baud rates and how they can be obtained from timer 2. 7.4.5 summary of baud rate equations timer 2 is in baud rate generating mode. if timer 2 is being clocked through pin t2(p1.0) the baud rate is: baud rate = timer 2 over?ow rate / 16 if timer 2 is being clocked internally, the baud rate is: baud rate = f osc / (16 (65536 - (rcap2h, rcap2l))) where f osc = oscillator frequency to obtain the reload value for rcap2h and rcap2l, the above equation can be rewritten as: rcap2h, rcap2l = 65536 - f osc / (16 baud rate) oscillatorfrequency 16 65536 rcap2h rcap2l , () C () () ----------------------------------------------------------------------------------------------- - table 22: timer 2 generated commonly used baud rates baud rate osc freq timer 2 rcap2h rcap2l 750k 12 mhz ff ff 19.2k 12 mhz ff d9 9.6k 12 mhz ff b2 4.8k 12 mhz ff 64 2.4k 12 mhz fe c8 600 12 mhz fb 1e
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 35 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.5 uarts the uart operates in all standard modes. enhancements over the standard 80c51 uart include framing error detection, and automatic address recognition. 7.5.1 mode 0 serial data enters and exits through rxd and txd outputs the shift clock. only 8 bits are transmitted or received, lsb ?rst. the baud rate is ?xed at 1 6 of the cpu clock frequency. uart con?gured to operate in this mode outputs serial clock on txd line no matter whether it sends or receives data on rxd line. 7.5.2 mode 1 10 bits are transmitted (through txd) or received (through rxd): a start bit (logical 0), 8 data bits (lsb ?rst), and a stop bit (logical 1). when data is received, the stop bit is stored in rb8 in special function register scon. the baud rate is variable and is determined by the timer 1 2 over?ow rate. 7.5.3 mode 2 11 bits are transmitted (through txd) or received (through rxd): start bit (logical 0), 8 data bits (lsb ?rst), a programmable 9th data bit, and a stop bit (logical 1). when data is transmitted, the 9th data bit (tb8 in scon) can be assigned the value of 0 or (e.g. the parity bit (p, in the psw) could be moved into tb8). when data is received, the 9th data bit goes into rb8 in special function register scon, while the stop bit is ignored. the baud rate is programmable to either 1 16 or 1 32 of the cpu clock frequency, as determined by the smod1 bit in pcon. 7.5.4 mode 3 11 bits are transmitted (through txd) or received (through rxd): a start bit (logical 0), 8 data bits (lsb ?rst), a programmable 9th data bit, and a stop bit (logical 1). in fact, mode 3 is the same as mode 2 in all respects except baud rate. the baud rate in mode 3 is variable and is determined by the timer 1 2 over?ow rate. 220 12 mhz f2 af 600 6 mhz fd 8f 220 6 mhz f9 57 table 22: timer 2 generated commonly used baud rates continued baud rate osc freq timer 2 rcap2h rcap2l table 23: scon - serial port control register (address 98h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol sm0/fe sm1 sm2 ren tb8 rb8 ti ri
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 36 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.5.5 framing error framing error (fe) is reported in the scon.7 bit if smod0 (pcon.6) = 1 . if smod0 = 0, scon.7 is the sm0 bit for the uart, it is recommended that sm0 is set up before smod0 is set to 1. 7.5.6 more about uart mode 1 reception is initiated by a detected 1-to-0 transition at rxd. for this purpose rxd is sampled at a rate of 16 times whatever baud rate has been established. when a transition is detected, the divide-by-16 counter is immediately reset to align its rollovers with the boundaries of the incoming bit times. table 24: scon - serial port control register (address 98h) bit description bit symbol description 7 sm0/fe the usage of this bit is determined by smod0 in the pcon register. if smod0 = 0, this bit is sm0, which with sm1, de?nes the serial port mode. if smod0 = 1, this bit is fe (framing error). fe is set by the receiver when an invalid stop bit is detected. once set, this bit cannot be cleared by valid frames but can only be cleared by software. (note: it is recommended to set up uart mode bits sm0 and sm1 before setting smod0 to 1.) 6 sm1 with sm0, de?nes the serial port mode (see ta b l e 2 5 below). 5 sm2 enables the multiprocessor communication feature in modes 2 and 3. in mode 2 or 3, if sm2 is set to 1, then rl will not be activated if the received 9th data bit (rb8) is 0. in mode 1, if sm2 = 1 then ri will not be activated if a valid stop bit was not received. in mode 0, sm2 should be 0. 4 ren enables serial reception. set by software to enable reception. clear by software to disable reception. 3 tb8 the 9th data bit that will be transmitted in modes 2 and 3. set or clear by software as desired. 2 rb8 in modes 2 and 3, is the 9th data bit that was received. in mode 1, it sm2 = 0, rb8 is the stop bit that was received. in mode 0, rb8 is unde?ned. 1 ti transmit interrupt ?ag. set by hardware at the end of the 8th bit time in mode 0, or at the stop bit in the other modes, in any serial transmission. must be cleared by software. 0 ri receive interrupt ?ag. set by hardware at the end of the 8th bit time in mode 0, or approximately halfway through the stop bit time in all other modes. (see sm2 for exceptions). must be cleared by software. table 25: scon - serial port control register (address 98h) sm0/sm1 mode de?nition sm0, sm1 uart mode baud rate 0 0 0: shift register cpu clock/6 0 1 1: 8-bit uart variable 1 0 2: 9-bit uart cpu clock/32 or cpu clock/16 1 1 3: 9-bit uart variable
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 37 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. the 16 states of the counter divide each bit time into 16ths. at the 7th, 8th, and 9th counter states of each bit time, the bit detector samples the value of rxd. the value accepted is the value that was seen in at least 2 of the 3 samples. this is done for noise rejection. if the value accepted during the ?rst bit time is not 0, the receive circuits are reset and the unit goes back to looking for another 1-to-0 transition. this is to provide rejection of false start bits. if the start bit proves valid, it is shifted into the input shift register, and reception of the rest of the frame will proceed. the signal to load sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the ?nal shift pulse is generated: (a) ri = 0, and (b) either sm2 = 0, or the received stop bit = 1 . if either of these two conditions is not met, the received frame is irretrievably lost. if both conditions are met, the stop bit goes into rb8, the 8 data bits go into sbuf, and ri is activated. 7.5.7 more about uart modes 2 and 3 reception is performed in the same manner as in mode 1. the signal to load sbuf and rb8, and to set ri, will be generated if, and only if, the following conditions are met at the time the ?nal shift pulse is generated: (a) ri = 0, and (b) either sm2 = 0, or the received 9th data bit = 1. if either of these conditions is not met, the received frame is irretrievably lost, and ri is not set. if both conditions are met, the received 9th data bit goes into rb8, and the ?rst 8 data bits go into sbuf. 7.5.8 multiprocessor communications uart modes 2 and 3 have a special provision for multiprocessor communications. in these modes, 9 data bits are received or transmitted. when data is received, the 9th bit is stored in rb8. the uart can be programmed so that when the stop bit is received, the serial port interrupt will be activated only if rb8 = 1 . this feature is enabled by setting bit sm2 in scon. one way to use this feature in multiprocessor systems is as follows: when the master processor wants to transmit a block of data to one of several slaves, it ?rst sends out an address byte which identi?es the target slave. an address byte differs from a data byte in a way that the 9th bit is 1 in an address byte and 0 in the data byte. with sm2 = 1, no slave will be interrupted by a data byte, i.e. the received 9th bit is 0. however, an address byte having the 9th bit set to 1 will interrupt all slaves, so that each slave can examine the received byte and see if it is being addressed or not. the addressed slave will clear its sm2 bit and prepare to receive the data (still 9 bits long) that follow. the slaves that werent being addressed leave their sm2 bits set and go on about their business, ignoring the subsequent data bytes. sm2 has no effect in mode 0, and in mode 1 can be used to check the validity of the stop bit, although this is better done with the framing error ?ag. when uart receives data in mode 1 and sm2 = 1 , the receive interrupt will not be activated unless a valid stop bit is received.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 38 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.5.9 automatic address recognition automatic address recognition is a feature which allows the uart to recognize certain addresses in the serial bit stream by using hardware to make the comparisons. this feature saves a great deal of software overhead by eliminating the need for the software to examine every serial address which passes by the serial port. this feature is enabled for the uart by setting the sm2 bit in scon. in the 9 bit uart modes, mode 2 and mode 3, the receive interrupt ?ag (ri) will be automatically set when the received byte contains either the given address or the broadcast' address. the 9 bit mode requires that the 9th information bit is a 1 to indicate that the received information is an address and not data. using the automatic address recognition feature allows a master to selectively communicate with one or more slaves by invoking the given slave address or addresses. all of the slaves may be contacted by using the broadcast address. two special function registers are used to de?ne the slaves address, saddr, and the address mask, saden. saden is used to de?ne which bits in the saddr are to be used and which bits are dont care. the saden mask can be logically anded with the saddr to create the given address which the master will use for addressing each of the slaves. use of the given address allows multiple slaves to be recognized while excluding others. this device uses the methods presented in figure 15 to determine if a given or broadcast address has been received or not. the following examples will help to show the versatility of this scheme. fig 15. schemes used by the uart to detect given and broadcast addresses when multiprocessor communications is enabled 002aaa527 rx_byte(7) saddr(7) saden(7) rx_byte(0) saddr(0) saden(0) . . . given_address_match logic used by p89lv51rd2 uart to detect 'given address' in received data saddr(7) saden(7) rx_byte(7) saddr(0) saden(0) rx_byte(0) . . . broadcast_address_match logic used by p89lv51rd2 uart to detect 'given address' in received data
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 39 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. in the above example saddr is the same and the saden data is used to differentiate between the two slaves. slave 0 requires a 0 in bit 0 and it ignores bit 1. slave 1 requires a 0 in bit 1 and bit 0 is ignored. a unique address for slave 0 would be 1100 0010 since slave 1 requires a 0 in bit 1. a unique address for slave 1 would be 1100 0001 since a 1 in bit 0 will exclude slave 0. both slaves can be selected at the same time by an address which has bit 0 = 0 (for slave 0) and bi t1=0 (for slave 1). thus, both could be addressed with 1100 0000. in a more complex system the following could be used to select slaves 1 and 2 while excluding slave 0: in the above example the differentiation among the 3 slaves is in the lower 3 address bits. slave 0 requires that bit 0 = 0 and it can be uniquely addressed by 1110 0110. slave 1 requires that bi t1=0anditcanbe uniquely addressed by 1110 0101. slave 2 requires that bit 2 = 0 and its unique address is 1110 0011. to select slaves 0 and 1 and exclude slave 2 use address 1110 0100, since it is necessary to make bit 2 = 1 to exclude slave 2. the broadcast address for each slave is created by taking the logical or of saddr and saden. zeros in this result are treated as dont-cares. in most cases, interpreting the dont-cares as ones, the broadcast address will be ff hexadecimal. upon reset saddr and saden are loaded with 0s. this produces a given address of all dont cares as well as a broadcast address of all dont cares'. this effectively disables the automatic addressing mode and allows the microcontroller to use standard uart drivers which do not make use of this feature. 7.6 serial peripheral interface 7.6.1 spi features ? master or slave operation ? 10 mhz bit frequency (max) table 26: slaves 0 and 1 scheme examples slave 0 saddr = 1100 0000 saden = 1111 1101 given = 1100 00x0 slave 1 saddr = 1100 0000 saden = 1111 1110 given = 1100 000x table 27: slaves 0, 1 and 2 scheme examples slave 0 saddr = 1110 0000 saden = 1111 1001 given = 1110 0xx0 slave 1 saddr = 1110 0000 saden = 1111 1010 given = 1110 0x0x slave 2 saddr = 1110 0000 saden = 1111 1100 given = 1110 00xx
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 40 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. ? lsb ?rst or msb ?rst data transfer ? four programmable bit rates ? end of transmission (spif) ? write collision ?ag protection (wcol) ? wake-up from idle mode (slave mode only) 7.6.2 spi description the serial peripheral interface (spi) allows high-speed synchronous data transfer between the p89v51rd2 and peripheral devices or between several p89v51rd2 devices. figure 16 shows the correspondence between master and slave spi devices. the sck pin is the clock output and input for the master and slave modes, respectively. the spi clock generator will start following a write to the master devices spi data register. the written data is then shifted out of the mosi pin on the master device into the mosi pin of the slave device. following a complete transmission of one byte of data, the spi clock generator is stopped and the spif ?ag is set. an spi interrupt request will be generated if the spi interrupt enable bit (spie) and the serial port interrupt enable bit (es) are both set. an external master drives the slave select input pin, ss/p1[4], low to select the spi module as a slave. if ss/p1[4] has not been driven low, then the slave spi unit is not active and the mosi/p1[5] port can also be used as an input port pin. cpha and cpol control the phase and polarity of the spi clock. figure 17 and figure 18 show the four possible combinations of these two bits. fig 16. spi master-slave interconnection. 002aaa528 8-bit shift register msb master lsb spi clock generator miso miso mosi mosi sck sck ss ss 8-bit shift register msb slave lsb v ss v dd table 28: spcr - spi control register (address d5h) bit allocation bit addressable; reset source(s): any reset; reset value: 00000000b bit 7 6 5 4 3 2 1 0 symbol spie spe dord mstr cpol cpha spr1 spr0
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 41 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. table 29: spcr - spi control register (address d5h) bit description bit symbol description 7 spie if both spie and es are set to one, spi interrupts are enabled. 6 spe spi enable bit. when set enables spi. 5 dord data transmission order. 0 = msb ?rst; 1 = lsb ?rst in data transmission. 4 mstr master/slave select. 1 = master mode, 0 = slave mode. 3 cpol clock polarity. 1 = sck is high when idle (active low), 0 = sck is low when idle (active high). 2 cpha clock phase control bit. 1 = shift triggered on the trailing edge of the clock; 0 = shift triggered on the leading edge of the clock. 1 spr1 spi clock rate select bit 1. along with spr0 controls the sck rate of the device when a master. spr1 and spr0 have no effect on the slave. see ta b l e 3 0 below. 0 spr0 spi clock rate select bit 0. along with spr1 controls the sck rate of the device when a master. spr1 and spr0 have no effect on the slave. see ta b l e 3 0 below. table 30: spcr - spi control register (address d5h) clock rate selection spr1 spr0 sck=f osc divided by 004 0116 1064 1 1 128 table 31: spsr - spi status register (address aah) bit allocation bit addressable; reset source(s): any reset; reset value: 00000000b bit 7 6 5 4 3 2 1 0 symbol spif wcol - - - - - - table 32: spsr - spi status register (address aah) bit description bit symbol description 7 spif spi interrupt ?ag. upon completion of data transfer, this bit is set to 1. if spie = 1 and es = 1, an interrupt is then generated. this bit is cleared by software. 6 wcol write collision flag. set if the spi data register is written to during data transfer. this bit is cleared by software. 5 to 0 - reserved for future use. should be set to 0 by user programs.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 42 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.7 watchdog timer the device offers a programmable watchdog timer (wdt) for fail safe protection against software deadlock and automatic recovery. to protect the system against software deadlock, the user software must refresh the wdt within a user-de?ned time period. if the software fails to do this periodical refresh, an internal hardware reset will be initiated if enabled (wdre = 1). the software can be designed such that the wdt times out if the program does not work properly. the wdt in the device uses the system clock (xtal1) as its time base. so strictly speaking, it is a watchdog counter rather than a watchdog timer. the wdt register will increment every 344,064 crystal clocks. the upper 8-bits of the time base register (wdtd) are used as the reload register of the wdt. the wdts ?ag bit is set by wdt over?ow and is not changed by wdt reset. user software can clear wdts by writing 1' to it. figure 19 provides a block diagram of the wdt. two sfrs (wdtc and wdtd) control watchdog timer operation. during idle mode, wdt operation is temporarily suspended, and resumes upon an interrupt exit from idle. the time-out period of the wdt is calculated as follows: fig 17. spi transfer format with cpha = 0. 002aaa529 msb sck cycle # (for reference) sck (cpol=0) sck (cpol=1) mosi (from master) miso (from slave) ss (to slave) 6 12345678 5 msb 654321lsb 4 3 2 1 lsb fig 18. spi transfer format with cpha = 1. 002aaa530 msb sck cycle # (for reference) sck (cpol=0) sck (cpol=1) mosi (from master) miso (from slave) ss (to slave) 6 12345678 5 msb654321 lsb 4 3 2 1 lsb
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 43 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. period = (255 - wdtd) 344064 1/f clk (xtal1) where wdtd is the value loaded into the wdtd register and f osc is the oscillator frequency. 7.8 programmable counter array (pca) the pca includes a special 16-bit timer that has ?ve 16-bit capture/compare modules associated with it. each of the modules can be programmed to operate in one of four modes: rising and/or falling edge capture, software timer, high-speed output, or pulse width modulator. each module has a pin associated with it in port 1. module 0 is connected to p1.3 (cex0), module 1 to p1.4 (cex1), etc. registers ch and cl contain current value of the free running up counting 16-bit pca timer. the pca timer is a common time base for all ?ve modules and can be programmed to run at: 1 6 the oscillator frequency, 1 2 the oscillator frequency, the timer 0 over?ow, or the input on the eci pin (p1.2). the timer count source is determined from the cps1 and cps0 bits in the cmod sfr (see ta b l e 3 5 and ta b l e 3 6 ). fig 19. block diagram of programmable watchdog timer 002aaa531 wdt upper byte wdt reset internal reset 344064 clks counter clk (xtal1) external rst wdtc wdtd table 33: wdtc - watchdog control register (address coh) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - - - wdout wdre wdts wdt swdt table 34: wdtc - watchdog control register (address coh) bit description bit symbol description 7 to 5 - reserved for future use. should be set to 0 by user programs. 4 wdout watchdog output enable. when this bit and wdre are both set, a watchdog reset will drive the reset pin active for 32 clocks. 3 wdre watchdog timer reset enable. when set enables a watchdog timer reset. 2 wdts watchdog timer reset ?ag, when set indicates that a wdt reset occurred. reset in software. 1 wdt watchdog timer refresh. set by software to force a wdt reset. 0 swdt start watchdog timer, when set starts the wdt. when cleared, stops the wdt.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 44 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. in the cmod sfr there are three additional bits associated with the pca. they are cidl which allows the pca to stop during idle mode, wdte which enables or disables the watchdog function on module 4, and ecf which when set causes an interrupt and the pca over?ow ?ag cf (in the ccon sfr) to be set when the pca timer over?ows. the watchdog timer function is implemented in module 4 of pca. the ccon sfr contains the run control bit for the pca (cr) and the ?ags for the pca timer (cf) and each module (ccf4:0). to run the pca the cr bit (ccon.6) must be set by software. the pca is shut off by clearing this bit. the cf bit (ccon.7) is set when the pca counter over?ows and an interrupt will be generated if the ecf bit in the cmod register is set. the cf bit can only be cleared by software. bits 0 through 4 of the ccon register are the ?ags for the modules (bit 0 for module 0, bit 1 for module 1, etc.) and are set by hardware when either a match or a capture occurs. these ?ags can only be cleared by software. all the modules share one interrupt vector. the pca interrupt system is shown in figure 21 . each module in the pca has a special function register associated with it. these registers are: ccapm0 for module 0, ccapm1 for module 1, etc. the registers contain the bits that control the mode that each module will operate in. the eccf bit (from ccapmn.0 where n = 0, 1, 2, 3, or 4 depending on the module) enables the ccfn ?ag in the ccon sfr to generate an interrupt when a match or compare occurs in the associated module (see figure 21 ). pwm (ccapmn.1) enables the pulse width modulation mode. the tog bit (ccapmn.2) when set causes the cex output associated with the module to toggle when there is a match between the pca counter and the modules capture/compare register. the match bit mat (ccapmn.3) when set will cause the ccfn bit in the ccon register to be set when there is a match between the pca counter and the modules capture/compare register. fig 20. 002aaa532 pca timer/counter time base for pca modules module0 16 bits 16 bits p1.3/cex0 module1 p1.4/cex1 module2 p1.5/cex2 module3 p1.6/cex3 module4 p1.7/cex4 module functions: 16-bit capture 16-bit timer 16-bit high speed output 8-bit pwm watchdog timer (module 4 only)
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 45 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. the next two bits capn (ccapmn.4) and capp (ccapmn.5) determine the edge that a capture input will be active on. the capn bit enables the negative edge, and the capp bit enables the positive edge. if both bits are set both edges will be enabled and a capture will occur for either transition. the last bit in the register ecom (ccapmn.6) when set enables the comparator function. there are two additional registers associated with each of the pca modules. they are ccapnh and ccapnl and these are the registers that store the 16-bit count when a capture occurs or a compare should occur. when a module is used in the pwm mode these registers are used to control the duty cycle of the output. fig 21. pca interrupt system. 002aaa533 pca timer/counter module0 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 module1 module2 module3 module4 ecf eccfn ien0.6 ec ien0.7 ea ccapmn.0 cmod.0 ccon (d8h) to interrupt priority decoder table 35: cmod - pca counter mode register (address d9h) bit allocation not bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol cidl wdte - - - cps1 cps0 ecf
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 46 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. table 36: cmod - pca counter mode register (address d9h) bit description bit symbol description 7 cidl counter idle control: cidl = 0 programs the pca counter to continue functioning during idle mode. cidl = 1 programs it to be gated off during idle. 6 wdte watchdog timer enable: wdte = 0 disables watchdog timer function on module 4. wdte = 1 enables it. 5 to 3 - reserved for future use. should be set to 0 by user programs. 2 to 1 cps1, cps0 pca count pulse select (see ta b l e 3 7 below). 0 ecf pca enable counter over?ow interrupt: ecf = 1 enables cf bit in ccon to generate an interrupt. ecf = 0 disables that function. table 37: cmod - pca counter mode register (address d9h) count pulse select cps1 cps0 select pca input 0 0 0 internal clock, f osc / 6 0 1 1 internal clock, f osc / 6 1 0 2 timer 0 over?ow 1 1 3 external clock at eci/p1.2 pin (max rate = f osc / 4) table 38: ccon - pca counter control register (address 0d8h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 table 39: ccon - pca counter control register (address 0d8h) bit description bit symbol description 7 cf pca counter over?ow flag. set by hardware when the counter rolls over. cf ?ags an interrupt if bit ecf in cmod is set. cf may be set by either hardware or software but can only be cleared by software. 6 cr pca counter run control bit. set by software to turn the pca counter on. must be cleared by software to turn the pca counter off. 5 - reserved for future use. should be set to 0 by user programs. 4 ccf4 pca module 4 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 3 ccf3 pca module 3 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 2 ccf2 pca module 2 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 1 ccf1 pca module 1 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 0 ccf0 pca module 0 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 47 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.8.1 pca capture mode to use one of the pca modules in the capture mode ( figure 22 ) either one or both of the ccapm bits capn and capp for that module must be set. the external cex input for the module (on port 1) is sampled for a transition. when a valid transition occurs the pca hardware loads the value of the pca counter registers (ch and cl) into the modules capture registers (ccapnl and ccapnh). table 40: ccapmn - pca modules compare/capture register (address ccapm0 0dah, ccapm1 0dbh, ccapm2 0dch, ccapm3 0ddh, ccapm4 0deh) bit alloc. not bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - ecomn cappn capnn matn togn pwmn eccfn table 41: ccapmn - pca modules compare/capture register (address ccapm0 0dah, ccapm1 0dbh, ccapm2 0dch, ccapm3 0ddh, ccapm4 0deh) bit desc. bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 ecomn enable comparator. ecomn = 1 enables the comparator function. 5 cappn capture positive, cappn = 1 enables positive edge capture. 4 capnn capture negative, capnn = 1 enables negative edge capture. 3 matn match. when matn = 1 a match of the pca counter with this modules compare/capture register causes the ccfn bit in ccon to be set, ?agging an interrupt. 2 togn toggle. when togn = 1, a match of the pca counter with this modules compare/capture register causes the cexn pin to toggle. 1 pwmn pulse width modulation mode. pwmn = 1 enables the cexn pin to be used as a pulse width modulated output. 0 eccfn enable ccf interrupt. enables compare/capture ?ag ccfn in the ccon register to generate an interrupt. table 42: pca module modes (ccapmn register) ecomn cappn capnn matn togn pwmn eccfn module function 0 0 0 0 0 0 0 no operation x 1 0 0 0 0 x 16-bit capture by a positive-edge trigger on cexn x 0 1 0 0 0 x 16-bit capture by a negative-edge trigger on cexn x 1 1 0 0 0 x 16-bit capture by any transition on cexn 1 0 0 1 0 0 x 16-bit software timer 1 0 0 1 1 0 x 16-bit high speed output 1 0 0 0 0 1 0 8-bit pwm 1 0 0 1 x 0 x watchdog timer
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 48 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. if the ccfn bit for the module in the ccon sfr and the eccfn bit in the ccapmn sfr are set then an interrupt will be generated. 7.8.2 16-bit software timer mode the pca modules can be used as software timers ( figure 23 ) by setting both the ecom and mat bits in the modules ccapmn register. the pca timer will be compared to the modules capture registers and when a match occurs an interrupt will occur if the ccfn (ccon sfr) and the eccfn (ccapmn sfr) bits for the module are both set. fig 22. pca capture mode. 002aaa538 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ccon (c0h) pca interrupt pca timer/counter - ecomn 0 000 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (c2h to c6h) ch cl ccapnh ccapnl capture (to ccfn) cexn
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 49 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.8.3 high speed output mode in this mode ( figure 24 ) the cex output (on port 1) associated with the pca module will toggle each time a match occurs between the pca counter and the modules capture registers. to activate this mode the tog, mat, and ecom bits in the modules ccapmn sfr must be set. fig 23. pca compare mode. 002aaa539 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ccon (c0h) pca interrupt - ecomn 00 100 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (c2h to c6h) 16-bit comparator pca timer/counter ch cl match (to ccfn) ccapnh ccapnl enable write to ccapnh write to ccapnl reset 01 fig 24. pca high speed output mode. 002aaa540 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 ccon (c0h) pca interrupt - ecomn 00 110 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (c2h to c6h) 16-bit comparator pca timer/counter ch cl match toggle cexn (to ccfn) ccapnh ccapnl enable write to ccapnh write to ccapnl reset 01
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 50 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.8.4 pulse width modulator mode all of the pca modules can be used as pwm outputs ( figure 25 ). output frequency depends on the source for the pca timer. all of the modules will have the same frequency of output because they all share one and only pca timer. the duty cycle of each module is independently variable using the modules capture register ccapnl.when the value of the pca cl sfr is less than the value in the modules ccapnl sfr the output will be low, when it is equal to or greater than the output will be high. when cl over?ows from ff to 00, ccapnl is reloaded with the value in ccapnh. this allows updating the pwm without glitches. the pwm and ecom bits in the modules ccapmn register must be set to enable the pwm mode. 7.8.5 pca watchdog timer an on-board watchdog timer is available with the pca to improve the reliability of the system without increasing chip count. watchdog timers are useful for systems that are susceptible to noise, power glitches, or electrostatic discharge. module 4 is the only pca module that can be programmed as a watchdog. however, this module can still be used for other modes if the watchdog is not needed. figure 25 shows a diagram of how the watchdog works. the user pre-loads a 16-bit value in the compare registers. just like the other compare modes, this 16-bit value is compared to the pca timer value. if a match is allowed to occur, an internal reset will be generated. this will not cause the rst pin to be driven high. users software then must periodically change (ccap4h,ccap4l) to keep a match from occurring with the pca timer (ch,cl). this code is given in the watchdog routine shown above. in order to hold off the reset, the user has three options: fig 25. pca pwm mode. 002aaa541 - ecomn 0 1 0 001 1 cappn capnn matn togn pwmn eccfn ccapmn, n = 0 to 4 (c2h to c6h) ccapnl 8-bit comparator pca timer/counter ccapnh cl enable cexn cl < ccapnl cl 3 ccapnl 0 1
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 51 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 1. periodically change the compare value so it will never match the pca timer. 2. periodically change the pca timer value so it will never match the compare values. 3. disable the watchdog by clearing the wdte bit before a match occurs and then re-enable it. the ?rst two options are more reliable because the watchdog timer is never disabled as in option #3. if the program counter ever goes astray, a match will eventually occur and cause an internal reset. the second option is also not recommended if other pca modules are being used. remember, the pca timer is the time base for all modules; changing the time base for other modules would not be a good idea. thus, in most applications the ?rst solution is the best option. ;call the following watchdog subroutine periodically. clr ea ;hold off interrupts mov ccap4l,#00 ;next compare value is within 255 counts of current pca timer value mov ccap4h,ch setb ea ;re-enable interrupts ret this routine should not be part of an interrupt service routine, because if the program counter goes astray and gets stuck in an in?nite loop, interrupts will still be serviced and the watchdog will keep getting reset. thus, the purpose of the watchdog would be defeated. instead, call this subroutine from the main program within 2 16 count of the pca timer. 7.9 security bit the security bit protects against software piracy and prevents the contents of the ?ash from being read by unauthorized parties in parallel programmer mode. it also protects against code corruption resulting from accidental erasing and programming to the internal ?ash memory. when the security bit is activated all parallel programming commands except for chip-erase are ignored (thus the device cannot be read). however, isp reads of the users code can still be performed if the serial number and length has not been programmed. therefore, when a user requests to program the security bit, the programmer should prompt the user and program a serial number into the device. 7.10 reset a system reset initializes the mcu and begins program execution at program memory location 0000h. the reset input for the device is the rst pin. in order to reset the device, a logic level high must be applied to the rst pin for at least two machine cycles (24 clocks), after the oscillator becomes stable. ale, psen are weakly pulled high during reset. during reset, ale and psen output a high level in order to perform a proper reset. this level must not be affected by external element. a system reset will not affect the 1 kbyte of on-chip ram while the device is running, however, the contents of the on-chip ram during power up are indeterminate.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 52 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.10.1 power-on reset at initial power up, the port pins will be in a random state until the oscillator has started and the internal reset algorithm has weakly pulled all pins high. powering up the device without a valid reset could cause the mcu to start executing instructions from an indeterminate location. such unde?ned states may inadvertently corrupt the code in the ?ash. when power is applied to the device, the rst pin must be held high long enough for the oscillator to start up (usually several milliseconds for a low frequency crystal), in addition to two machine cycles for a valid power-on reset. an example of a method to extend the rst signal is to implement a rc circuit by connecting the rst pin to v dd through a 10 m f capacitor and to v ss through an 8.2 k w resistor as shown in figure 26 . note that if an rc circuit is being used, provisions should be made to ensure the v dd rise time does not exceed 1 millisecond and the oscillator start-up time does not exceed 10 milliseconds. for a low frequency oscillator with slow start-up time the reset signal must be extended in order to account for the slow start-up time. this method maintains the necessary relationship between v dd and rst to avoid programming at an indeterminate location, which may cause corruption in the code of the ?ash. the power-on detection is designed to work as power-up initially, before the voltage reaches the brown-out detection level. the pof ?ag in the pcon register is set to indicate an initial power-up condition. the pof ?ag will remain active until cleared by software. please refer to the pcon register de?nition for detail information. following reset, the p89v51rd2 will either enter the softice mode (if previously enabled via isp command) or attempt to autobaud to the isp boot loader. if this autobaud is not successful within about 400 ms, the device will begin execution of the user code. fig 26. power-on reset circuit. 002aaa543 v dd v dd 8.2 k w rst xtal2 xtal1 c 1 c 2 10 m f
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 53 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.10.2 software reset the software reset is executed by changing fcf[1] (swr) from 0 to 1. a software reset will reset the program counter to address 0000h. all sfr registers will be set to their reset values, except fcf[1] (swr), wdtc[2] (wdts), and ram data will not be altered. 7.10.3 brown-out detection reset the device includes a brown-out detection circuit to protect the system from severed supplied voltage v dd ?uctuations. the p89v51rd2s brown-out detection threshold is 3.85 v. for brown-out voltage parameters, please refer to ta b l e 6 7 and ta b l e 6 8 . when v dd drops below this voltage threshold, the brown-out detector triggers the circuit to generate a brown-out interrupt but the cpu still runs until the supplied voltage returns to the brown-out detection voltage v bod . the default operation for a brown-out detection is to cause a processor reset. v dd must stay below v bod at least four oscillator clock periods before the brown-out detection circuit will respond. brown-out interrupt can be enabled by setting the ebo bit in iea register (address e8h, bit 3). if ebo bit is set and a brown-out condition occurs, a brown-out interrupt will be generated to execute the program at location 004bh. it is required that the ebo bit be cleared by software after the brown-out interrupt is serviced. clearing ebo bit when the brown-out condition is active will properly reset the device. if brown-out interrupt is not enabled, a brown-out condition will reset the program to resume execution at location 0000h. 7.10.4 interrupt priority and polling sequence the device supports eight interrupt sources under a four level priority scheme. ta b l e 4 3 summarizes the polling sequence of the supported interrupts. note that the spi serial interface and the uart share the same interrupt vector. (see figure 27 ). table 43: interrupt polling sequence description interrupt flag vector address interrupt enable interrupt priority service priority wake-up power-down ext. int0 ie0 0003h ex0 px0/h 1 (highest) yes brown-out - 004bh ebo pbo/h 2 no t0 tf0 000bh et0 pt0/h 3 no ext. int1 ie1 0013h ex1 px1/h 4 yes t1 tf1 001bh et1 pt1/h 5 no pca cf/ccfn 0033h ec ppch 6 no uart/spi ti/ri/spif 0023h es ps/h 7 no t2 tf2, exf2 002bh et2 pt2/h 8 no
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 54 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. fig 27. interrupt structure. 002aaa544 ie1 int1# individual enables tf1 tf0 ri 0 1 global disable highest priority interrupt interrupt polling sequence lowest priority interrup it1 int0# ie & iea registers ip/iph/ipa/ipah registers tf2 exf2 ti spie spif brown-out cf ecf ccfn eccfn ie0 0 1 it0
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 55 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. table 44: ien0 - interrupt enable register 0 (address a8h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol ea ec et2 es et1 ex1 et0 ex0 table 45: ien0 - interrupt enable register 0 (address a8h) bit description bit symbol description 7 ea interrupt enable bit: ea = 1 interrupt(s) can be serviced, ea = 0 interrupt servicing disabled. 6 ec pca interrupt enable bit. 5 et2 timer 2 interrupt enable. 4 es serial port interrupt enable 3 et1 timer 1 overflow interrupt enable. 2 ex1 external interrupt 1 enable. 1 et0 timer 0 overflow interrupt enable. 0 ex0 external interrupt 0 enable. table 46: ien1 - interrupt enable register 1 (address e8h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - - - - ebo - - - table 47: ien1 - interrupt enable register 1 (address e8h) bit description bit symbol description 7 to 4 - reserved for future use. should be set to 0 by user programs. 3 ebo brown-out interrupt enable. 1 = enable, 0 = disable. 2 to 0 - reserved for future use. should be set to 0 by user programs. table 48: ip0 - interrupt priority 0 low register (address b8h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - ppc pt2 ps pt1 px1 pt0 px0 table 49: ip0 - interrupt priority 0 low register (address b8h) bit description bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 ppc pca interrupt priority low bit. 5 pt2 timer 2 interrupt priority low bit. 4 ps serial port interrupt priority low bit. 3 pt1 timer 1 interrupt priority low bit. 2 px1 external interrupt 1 priority low bit. 1 pt0 timer 0 interrupt priority low bit. 0 px0 external interrupt 0 priority low bit.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 56 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.11 power-saving modes the device provides two power saving modes of operation for applications where power consumption is critical. the two modes are idle and power-down, see ta b l e 5 6 . table 50: ip0h - interrupt priority 0 high register (address b7h) bit allocation not bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - ppch pt2h psh pt1h px1h pt0h px0h table 51: ip0h - interrupt priority 0 high register (address b7h) bit description bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 ppch pca interrupt priority high bit. 5 pt2h timer 2 interrupt priority high bit. 4 psh serial port interrupt priority high bit. 3 pt1h timer 1 interrupt priority high bit. 2 px1h external interrupt 1 priority high bit. 1 pt0h timer 0 interrupt priority high bit. 0 px0h external interrupt 0 priority high bit. table 52: ip1 - interrupt priority 1 register (address f8h) bit allocation bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - - - pbo - - - - table 53: ip1 - interrupt priority 1 register (address f8h) bit description bit symbol description 7 to 5 - reserved for future use. should be set to 0 by user programs. 4 pbo brown-out interrupt priority bit. 3 to 0 - reserved for future use. should be set to 0 by user programs. table 54: ip1h - interrupt priority 1 high register (address f7h) bit allocation not bit addressable; reset value: 00h bit 7 6 5 4 3 2 1 0 symbol - - - pboh - - - - table 55: ip1h - interrupt priority 1 high register (address f7h) bit description bit symbol description 7 to 5 - reserved for future use. should be set to 0 by user programs. 4 pboh brown-out interrupt priority bit. 3 to 0 - reserved for future use. should be set to 0 by user programs.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 57 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.11.1 idle mode idle mode is entered setting the idl bit in the pcon register. in idle mode, the program counter (pc) is stopped. the system clock continues to run and all interrupts and peripherals remain active. the on-chip ram and the special function registers hold their data during this mode. the device exits idle mode through either a system interrupt or a hardware reset. exiting idle mode via system interrupt, the start of the interrupt clears the idl bit and exits idle mode. after exit the interrupt service routine, the interrupted program resumes execution beginning at the instruction immediately following the instruction which invoked the idle mode. a hardware reset starts the device similar to a power-on reset. 7.11.2 power-down mode the power-down mode is entered by setting the pd bit in the pcon register. in the power-down mode, the clock is stopped and external interrupts are active for level sensitive interrupts only. sram contents are retained during power-down, the minimum v dd level is 2.0 v. the device exits power-down mode through either an enabled external level sensitive interrupt or a hardware reset. the start of the interrupt clears the pd bit and exits power-down. holding the external interrupt pin low restarts the oscillator, the signal must hold low at least 1024 clock cycles before bringing back high to complete the exit. upon interrupt signal restored to logic v ih , the interrupt service routine program execution resumes beginning at the instruction immediately following the instruction which invoked power-down mode. a hardware reset starts the device similar to power-on reset. to exit properly out of power-down, the reset or external interrupt should not be executed before the v dd line is restored to its normal operating voltage. be sure to hold v dd voltage long enough at its normal operating level for the oscillator to restart and stabilize (normally less than 10 ms).
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 58 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.12 system clock and clock options 7.12.1 clock input options and recommended capacitor values for oscillator shown in figure 28 are the input and output of an internal inverting ampli?er (xtal1, xtal2), which can be con?gured for use as an on-chip oscillator. when driving the device from an external clock source, xtal2 should be left disconnected and xtal1 should be driven. at start-up, the external oscillator may encounter a higher capacitive load at xtal1 due to interaction between the ampli?er and its feedback capacitance. however, the capacitance will not exceed 15 pf once the external signal meets the v il and v ih speci?cations. crystal manufacturer, supply voltage, and other factors may cause circuit performance to differ from one application to another. c1 and c2 should be adjusted appropriately for each design. ta b l e 5 7 shows the typical values for c1 and c2 vs. crystal type for various frequencies more speci?c information about on-chip oscillator design can be found in the flashflex51 oscillator circuit design considerations application note. table 56: power-saving modes mode initiated by state of mcu exited by idle mode software (set idl bit in pcon) mov pcon, #01h; clk is running. interrupts, serial port and timers/counters are active. program counter is stopped. ale and psen signals at a high level during idle. all registers remain unchanged. enabled interrupt or hardware reset. start of interrupt clears idl bit and exits idle mode, after the isr reti instruction, program resumes execution beginning at the instruction following the one that invoked idle mode. a user could consider placing two or three nop instructions after the instruction that invokes idle mode to eliminate any problems. a hardware reset restarts the device similar to a power-on reset. power-down mode software (set pd bit in pcon) mov pcon, #02h; clk is stopped. on-chip sram and sfr data is maintained. ale and psen signals at a low level during power -down. external interrupts are only active for level sensitive interrupts, if enabled. enabled external level sensitive interrupt or hardware reset. start of interrupt clears pd bit and exits power-down mode, after the isr reti instruction program resumes execution beginning at the instruction following the one that invoked power-down mode. a user could consider placing two or three nop instructions after the instruction that invokes power-down mode to eliminate any problems. a hardware reset restarts the device similar to a power-on reset. table 57: recommended values for c1 and c2 by crystal type crystal c1=c2 quartz 20 pf to 30 pf ceramic 40 pf to 50 pf
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 59 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 7.12.2 clock doubling option by default, the device runs at 12 clocks per machine cycle (x1 mode). the device has a clock doubling option to speed up to 6 clocks per machine cycle (please see ta b l e 5 8 ). clock double mode can be enabled either by an external programmer or using iap. when set, the edc bit in fst register will indicate 6 clock mode. the clock double mode is only for doubling the internal system clock and the internal ?ash memory, i.e. ea = 1. to access the external memory and the peripheral devices, careful consideration must be taken. also note that the crystal output (xtal2) will not be doubled. using the on-chip oscillator external clock drive fig 28. oscillator characteristics. 002aaa543 xtal2 xtal1 v ss c 1 c 2 002aaa546 xtal2 nc xtal1 external oscillator signal v ss table 58: clock doubling features device standard mode (x1) clock double mode (x2) clocks per machine cycle max. external clock frequency (mhz) clocks per machine cycle max. external clock frequency (mhz) p89v51rd2 12 40 6 20 table 59: fst - flash status register (address b6) bit allocation not bit addressable; reset value: xxxxx0xxb bit 7 6 5 4 3 2 1 0 symbol - sb - - edc - - - table 60: fst - flash status register (address b6) bit description bit symbol description 7 - reserved for future use. should be set to 0 by user programs. 6 sb security bit. 5 to 4 - reserved for future use. should be set to 0 by user programs. 3 edc enable double clock. 2 to 0 - reserved for future use. should be set to 0 by user programs.
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 60 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 8. limiting values [1] outputs shorted for no more than one second. no more than one output shorted at a time. (based on package heat transfer limitations, not device power consumption.) 9. recommended operating conditions table 61: limiting values in accordance with the absolute maximum rating system (iec 60134). parameters are valid over operating temperature range unless otherwise speci?ed. all voltages are with respect to v ss unless otherwise noted. symbol parameter conditions min max unit t amb(bias) operating bias ambient temperature - 55 +125 c t stg storage temperature range - 65 +150 c v ea voltage on ea pin to v ss - 0.5 14 v v n dc voltage on any pin to ground potential - 0.5 v dd + 0.5 v v it transient voltage (<20 ns) on any other pin to v ss - 1.0 v dd + 1.0 v i ol(i/o) maximum i ol per i/o pins p1.5, p1.6, p1.7 -20ma i ol(i/o) maximum i ol per i/o for all other pins - 15 ma p tot(pack) total power dissipation per package t amb =25 c - 1.5 w through hole lead soldering temperature 10 seconds - 300 c surface mount lead soldering temperature 3 seconds - 240 c output short circuit current [1] -50ma table 62: operating range symbol description min max unit t amb ambient temperature under bias commercial 0 +70 c industrial - 40 +85 c v dd supply voltage 4.5 5.5 v f osc oscillator frequency 0 40 mhz oscillator frequency for in-application programming 0.25 40 mhz
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 61 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. [1] this parameter is measured only for initial quali?cation and after a design or process change that could affect this parameter. [1] see figure 35 and figure 37 . [1] this parameter is measured only for initial quali?cation and after a design or process change that could affect this parameter. [1] this parameter is measured only for initial quali?cation and after a design or process change that could affect this parameter. table 63: reliability characteristics symbol parameter minimum speci?cation units test method n end [1] endurance 10,000 cycles jedec standard a117 t dr [1] data retention 100 years jedec standard a103 i lt h [1] latch up 100 + i dd ma jedec standard 78 table 64: ac conditions of test [1] input rise/fall time 10 ns output load c l = 100 pf table 65: recommended system power-up timings symbol parameter minimum unit t pu-read [1] power-up to read operation 100 m s t pu-write [1] power-up to write operation 100 m s table 66: pin impedance (v dd = 3.3 v, t amb =25 c, f = 1 mhz, other pins open) parameter description test condition maximum unit c i/o [1] i/o pin capacitance v i/o =0v 15 pf c in [1] input capacitance v in =0v 12 pf l pin pin inductance 20 nh
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 62 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 10. static characteristics [1] under steady state (non-transient) conditions, i ol must be externally limited as follows: a) maximum i ol per 8-bit port: 26 ma b) maximum i ol total for all outputs: 71 ma c) if i ol exceeds the test condition, v oh may exceed the related speci?cation. pins are not guaranteed to sink current greater than the listed test conditions. table 67: dc electrical characteristics t amb =0 c to +70 c or - 40 cto+85 c; v dd = 4.5 v to 5.5 v; v ss =0v symbol parameter conditions min max unit v il low-level input voltage 4.5 v < v dd < 5.5 v - 0.5 0.2v dd - 0.1 v v ih high-level input voltage 4.5 v < v dd < 5.5 v 0.2v dd + 0.9 v dd + 0.5 v v ih1 high-level input voltage (xtal1, rst) 4.5 v < v dd < 5.5 v 0.7v dd v dd + 0.5 v v ol low-level output voltage (ports 1.5, 1.6, 1.7) v dd = 4.5 v; i ol = 16 ma - 1.0 v v ol low-level output voltage (ports 1, 2, 3) [1] v dd = 4.5 v i ol = 100 m a - 0.3 v i ol = 1.6 ma - 0.45 v i ol = 3.5 ma - 1.0 v v ol1 low-level output voltage (port 0, ale, psen) [1][3] v dd = 4.5 v i ol = 200 m a - 0.3 v i ol = 3.2 ma - 0.45 v v oh high-level output voltage (ports 1, 2, 3, ale, psen) [4] v dd = 4.5 v i oh = -10 m av dd - 0.3 - v i oh = -30 m av dd - 0.7 - v i oh = -60 m av dd - 1.5 - v v oh1 high-level output voltage (port 0 in external bus mode) [4] v dd = 4.5 v i oh = -200 m av dd - 0.3 - v i oh = -3.2 ma v dd - 0.7 - v v bod brown-out detection voltage 3.85 4.15 v i il logic 0 input current (ports 1, 2, 3) v in = 0.4 v - - 75 m a i tl logic 1-to-0 transition current (ports 1, 2, 3) [5] v in =2v - - 650 m a i li input leakage current (port 0) 0.45 v < v in philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 63 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. [2] capacitive loading on ports 0 and 2 may cause spurious noise to be superimposed on the v ol s of ale and ports 1 and 3. the noise due to external bus capacitance discharging into the port 0 and 2 pins when the pins make 1-to-0 transitions during bus operatio ns. in the worst cases (capacitive loading > 100 pf), the noise pulse on the ale pin may exceed 0.8 v. in such cases, it may be desirable to qualify ale with a schmitt trigger, or use an address latch with a schmitt trigger strobe input. [3] load capacitance for port 0, ale and psen = 100 pf, load capacitance for all other outputs = 80 pf. [4] capacitive loading on ports 0 and 2 may cause the v oh on ale and psen to momentarily fall below the v dd - 0.7 speci?cation when the address bits are stabilizing. [5] pins of ports 1, 2 and 3 source a transition current when they are being externally driven from 1 to 0. the transition curre nt reaches its maximum value when v in is approximately 2 v. [6] pin capacitance is characterized but not tested. ea = 25 pf (max). fig 29. i dd vs. frequency. 50 40 30 20 10 0 510152025303540 i dd (ma) internal clock frequency (mhz) maximum idle i dd typical idle i dd typical active i dd 002aaa813 maximum active i dd
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 64 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 11. dynamic characteristics [1] calculated values are for x1 mode only. table 68: ac characteristics over operating conditions: load capacitance for port 0, ale, and psen = 100 pf; load capacitance for all other outputs = 80 pf t amb =0 c to +70 c or - 40 cto+85 c; v dd = 4.5 v to 5.5 v @ 40 mhz; v ss =0v symbol parameter 40 mhz (x1 mode) 20 mhz (x2 mode) [1] variable unit min max min max 1/t clcl x1 mode oscillator frequency 0 40 0 40 mhz 1/2t clcl x2 mode oscillator frequency 0 20 0 20 mhz t lhll ale pulse width 35 - 2t clcl - 15 - ns t avll address valid to ale low 10 - t clcl - 15 - ns t llax address hold after ale low 10 - t clcl - 15 - ns t lliv ale low to valid instruction in - 55 - 4t clcl - 45 ns t llpl ale low to psen low 10 - t clcl - 15 - ns t plph psen pulse width 60 - t clcl - 15 - ns t pliv psen low to valid instruction in - 25 - 3t clcl - 50 ns t pxix input instruction hold after psen - - 0 - ns t pxiz input instruction ?oat after psen - 10 - t clcl - 15 ns t pxav psen to address valid 17 - t clcl - 8- ns t aviv address to valid instruction in - 65 - 5t clcl - 60 ns t plaz psen low to address ?oat - 10 - 10 ns t rlrh rd pulse width 120 - 6t clcl - 30 - ns t wlwh write pulse width ( wr) 120 - 6t clcl - 30 - ns t rldv rd low to valid data in - 75 - 5t clcl - 50 ns t rhdx data hold after rd 0 - 0 - ns t rhdz data ?oat after rd - 38 - 2t clcl - 12 ns t lldv ale low to valid data in - 150 - 8t clcl - 50 ns t avdv address to valid data in - 150 - 9t clcl - 75 ns t llwl ale low to rd or wr low 60 90 3t clcl - 15 3t clcl + 15 ns t avwl address to rd or wr low 70 - 4t clcl - 30 - ns t whqx data hold after wr 5 - t clcl - 20 - ns t qvwh data valid to wr high 125 - 7t clcl - 50 - ns t rlaz rd low to address ?oat - 0 - 0 ns t whlh rd to wr high to ale high 10 40 t clcl - 15 t clcl + 15 ns
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 65 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 11.1 explanation of symbols each timing symbol has 5 characters. the ?rst character is always a t (stands for time). the other characters, depending on their positions, stand for the name of a signal or the logical status of that signal. the following is a list of all the characters and what they stand for. a address c clock d input data h logic level high i instruction (program memory contents) l logic level low or ale p psen q output data r rd signal t time v valid w wr signal x no longer a valid logic level z high impedance (float) example: t avll = time from address valid to ale low t llpl = time from ale low to psen low fig 30. external program memory read cycle. 002aaa548 port 2 psen ale a0 - a7 t llax t plaz t pxiz t llpl t aviv t avll t lhll t lliv t pliv t plph instr in a8 - a15 a8 - a15 a0 - a7 port 0 t pxix t pxav
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 66 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. fig 31. external data memory read cycle. 002aaa549 port 2 port 0 wr psen ale t lhll p2[7:0] or a8-a15 from dph a0-a7 from ri or dpl data out instr in t avll t avwl t llwl t llax t wlwh t qvwh t whqx t whlh a8-a15 from pch a0-a7 from pcl fig 32. external data memory write cycle. 002aaa550 port 2 port 0 wr psen ale t lhll p2[7:0] or a8-a15 from dph a0-a7 from ri or dpl data out instr in t avll t avwl t llwl t llax t wlwh t qvwh t whqx t whlh a8-a15 from pch a0-a7 from pcl table 69: external clock drive symbol parameter oscillator unit 40 mhz variable min max min max 1/t clcl oscillator frequency - - 0 40 mhz t clcl 25 - - - ns t chcx high time 8.75 - 0.35t clcl 0.65t clcl ns
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 67 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. t clcx low time 8.75 - 0.35t clcl 0.65t clcl ns t clch rise time - 10 - - ns t chcl fall time - 10 - - ns table 69: external clock drive continued symbol parameter oscillator unit 40 mhz variable min max min max fig 33. external clock drive waveform. 002aaa551 0.2 v dd - 0.1 0.45 v t chcl t clcl t clch t clcx t chcx 0.7v dd v dd - 0.5 table 70: serial port timing symbol parameter oscillator unit 40 mhz variable min max min max t xlxl serial port clock cycle time 0.3 - 12t clcl - m s t qvxh output data set-up to clock rising edge 117 - 10t clcl - 133 - ns t xhqx output data hold after clock rising edge 0- 2t clcl - 50 - ns t xhdx input data hold after clock rising edge 0- 0 - ns t xhdv clock rising edge to input data valid - 117 - 10t clcl - 133 ns fig 34. shift register mode timing waveforms. 002aaa552 ale 0 instruction clock output data write to sbuf valid valid valid valid valid valid valid valid input data clear ri 01 2 34 567 t xlxl t qvxh t xhqx t xhdv t xhdx set ti set r i 1 2 3 4 5 6 7 8
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 68 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. ac inputs during testing are driven at v iht (v dd - 0.5 v) for logic 1 and v ilt (0.45 v) for a logic 0. measurement reference points for inputs and outputs are at v ht (0.2v dd + 0.9) and v lt (0.2v dd - 0.1) fig 35. ac testing input/output test waveform. 002aaa553 v lt v ht v iht v ilt note: v ht - v high test v lt - v low test v iht -v input high test v ilt - v input low test for timing purposes, a port pin is no longer ?oating when a 100 mv change from load voltage occurs, and begins to ?oat when a 100 mv change from the loaded v oh /v ol level occurs. i oh /i ol = 20 ma. fig 36. float waveform. 002aaa554 v load + 0.1v v load - 0.1v v oh - 0.1v timing reference points v ol + 0.1v v load fig 37. test load example. 002aaa555 to dut to tester c l
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 69 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. all other pins disconnected fig 38. i dd test condition, active mode. 002aaa556 v dd v dd v dd v dd p0 ea rst xtal2 (nc) clock signal xtal1 v ss i dd all other pins disconnected fig 39. i dd test condition, idle mode. 002aaa557 v dd v dd v dd p0 ea rst xtal2 (nc) clock signal xtal1 v ss i dd all other pins disconnected fig 40. i dd test condition, power-down mode. 002aaa558 v dd v dd v dd = 2 v v dd p0 ea rst xtal2 (nc) xtal1 v ss i dd
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 70 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 12. package outline fig 41. pdip40 package outline. unit a max. 1 2 b 1 cd e e m h l references outline version european projection issue date iec jedec jeita mm inches dimensions (inch dimensions are derived from the original mm dimensions) sot129-1 99-12-27 03-02-13 a min. a max. b z max. w m e e 1 1.70 1.14 0.53 0.38 0.36 0.23 52.5 51.5 14.1 13.7 3.60 3.05 0.254 2.54 15.24 15.80 15.24 17.42 15.90 2.25 4.7 0.51 4 0.067 0.045 0.021 0.015 0.014 0.009 2.067 2.028 0.56 0.54 0.14 0.12 0.01 0.1 0.6 0.62 0.60 0.69 0.63 0.089 0.19 0.02 0.16 051g08 mo-015 sc-511-40 m h c (e ) 1 m e a l seating plane a 1 w m b 1 e d a 2 z 40 1 21 20 b e pin 1 index 0 5 10 mm scale note 1. plastic or metal protrusions of 0.25 mm (0.01 inch) maximum per side are not included. (1) (1) (1) dip40: plastic dual in-line package; 40 leads (600 mil) sot129-1
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 71 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. fig 42. tqfp44 package outline. unit a max. a 1 a 2 a 3 b p ce (1) eh e ll p z y w v q references outline version european projection issue date iec jedec jeita mm 1.2 0.15 0.05 1.05 0.95 0.25 0.45 0.30 0.18 0.12 10.1 9.9 0.8 12.15 11.85 1.2 0.8 7 0 o o 0.2 0.1 0.2 1 dimensions (mm are the original dimensions) note 1. plastic or metal protrusions of 0.25 mm maximum per side are not included. 0.75 0.45 sot376-1 137e08 ms-026 00-01-19 02-03-14 d (1) (1) (1) 10.1 9.9 h d 12.15 11.85 e z 1.2 0.8 d b p e e b 11 d h b p e h v m b d z d a z e e v m a 1 44 34 33 23 22 12 q a 1 a l p detail x l (a ) 3 a 2 x y c w m w m 0 2.5 5 mm scale tqfp44: plastic thin quad flat package; 44 leads; body 10 x 10 x 1.0 mm sot376-1 pin 1 index
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 72 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. fig 43. plcc44 package outline. unit a a 1 min. a 4 max. b p ey w v b references outline version european projection issue date iec jedec jeita mm 4.57 4.19 0.51 3.05 0.53 0.33 0.021 0.013 16.66 16.51 1.27 17.65 17.40 2.16 45 o 0.18 0.1 0.18 dimensions (mm dimensions are derived from the original inch dimensions) note 1. plastic or metal protrusions of 0.25 mm (0.01 inch) maximum per side are not included. sot187-2 d (1) e (1) 16.66 16.51 h d h e 17.65 17.40 z d (1) max. z e (1) max. 2.16 b 1 0.81 0.66 k 1.22 1.07 0.180 0.165 0.02 0.12 a 3 0.25 0.01 0.656 0.650 0.05 0.695 0.685 0.085 0.007 0.004 0.007 l p 1.44 1.02 0.057 0.040 0.656 0.650 0.695 0.685 e d e e 16.00 14.99 0.63 0.59 16.00 14.99 0.63 0.59 0.085 0.032 0.026 0.048 0.042 29 39 44 1 6 717 28 18 40 detail x (a ) 3 b p w m a 1 a a 4 l p b 1 b k x y e e b d h e e e h v m b d z d a z e e v m a pin 1 index 112e10 ms-018 edr-7319 0 5 10 mm scale 99-12-27 01-11-14 inches plcc44: plastic leaded chip carrier; 44 leads sot187-2 d e
philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core product data rev. 01 01 march 2004 73 of 75 9397 750 12964 ? koninklijke philips electronics n.v. 2004. all rights reserved. 13. revision history table 71: revision history rev date cpcn description 01 20040301 - product data (9397 750 12964)
9397 750 12964 philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core ? koninklijke philips electronics n.v. 2004. all rights reserved. product data rev. 01 01 march 2004 74 of 75 contact information for additional information, please visit http://www.semiconductors.philips.com . for sales of?ce addresses, send e-mail to: sales.addresses@www.semiconductors.philips.com . fax: +31 40 27 24825 14. data sheet status [1] please consult the most recently issued data sheet before initiating or completing a design. [2] the product status of the device(s) described in this data sheet may have changed since this data sheet was published. the l atest information is available on the internet at url http://www.semiconductors.philips.com. [3] for data sheets describing multiple type numbers, the highest-level product status determines the data sheet status. 15. de?nitions short-form speci?cation the data in a short-form speci?cation is extracted from a full data sheet with the same type number and title. for detailed information see the relevant data sheet or data handbook. limiting values de?nition limiting values given are in accordance with the absolute maximum rating system (iec 60134). stress above one or more of the limiting values may cause permanent damage to the device. these are stress ratings only and operation of the device at these or at any other conditions above those given in the characteristics sections of the speci?cation is not implied. exposure to limiting values for extended periods may affect device reliability. application information applications that are described herein for any of these products are for illustrative purposes only. philips semiconductors make no representation or warranty that such applications will be suitable for the speci?ed use without further testing or modi?cation. 16. disclaimers life support these products are not designed for use in life support appliances, devices, or systems where malfunction of these products can reasonably be expected to result in personal injury. philips semiconductors customers using or selling these products for use in such applications do so at their own risk and agree to fully indemnify philips semiconductors for any damages resulting from such application. right to make changes philips semiconductors reserves the right to make changes in the products - including circuits, standard cells, and/or software - described or contained herein in order to improve design and/or performance. when the product is in full production (status production), relevant changes will be communicated via a customer product/process change noti?cation (cpcn). philips semiconductors assumes no responsibility or liability for the use of any of these products, conveys no licence or title under any patent, copyright, or mask work right to these products, and makes no representations or warranties that these products are free from patent, copyright, or mask work right infringement, unless otherwise speci?ed. level data sheet status [1] product status [2][3] de?nition i objective data development this data sheet contains data from the objective speci?cation for product development. philips semiconductors reserves the right to change the speci?cation in any manner without notice. ii preliminary data quali?cation this data sheet contains data from the preliminary speci?cation. supplementary data will be published at a later date. philips semiconductors reserves the right to change the speci?cation without notice, in order to improve the design and supply the best possible product. iii product data production this data sheet contains data from the product speci?cation. philips semiconductors reserves the right to make changes at any time in order to improve the design, manufacturing and supply. relevant changes will be communicated via a customer product/process change noti?cation (cpcn).
? koninklijke philips electronics n.v. 2004. printed in the u.s.a. all rights are reserved. reproduction in whole or in part is prohibited without the prior written consent of the copyright owner. the information presented in this document does not form part of any quotation or contract, is believed to be accurate and reliable and may be changed without notice. no liability will be accepted by the publisher for any consequence of its use. publication thereof does not convey nor imply any license under patent- or other industrial or intellectual property rights. date of release: 01 march 2004 document order number: 9397 750 12964 contents philips semiconductors p89v51rd2 8-bit microcontrollers with 80c51 core 1 general description . . . . . . . . . . . . . . . . . . . . . . 1 2 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 3 ordering information . . . . . . . . . . . . . . . . . . . . . 2 3.1 ordering options . . . . . . . . . . . . . . . . . . . . . . . . 2 4 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 pinning information . . . . . . . . . . . . . . . . . . . . . . 4 5.1 pinning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5.2 pin description . . . . . . . . . . . . . . . . . . . . . . . . . 7 6 special function registers . . . . . . . . . . . . . . . . 10 7 functional description . . . . . . . . . . . . . . . . . . 14 7.1 memory organization . . . . . . . . . . . . . . . . . . . 14 7.1.1 flash program memory. . . . . . . . . . . . . . . . . . 14 7.1.2 data ram memory . . . . . . . . . . . . . . . . . . . . . 14 7.1.3 expanded data ram addressing . . . . . . . . . . 14 7.1.4 dual data pointers. . . . . . . . . . . . . . . . . . . . . . 17 7.2 flash memory in-application programming . . 18 7.2.1 flash organization . . . . . . . . . . . . . . . . . . . . . 18 7.2.2 boot block . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 7.2.3 power-on reset code execution . . . . . . . . . . . 19 7.2.4 in-system programming (isp) . . . . . . . . . . . . 19 7.2.5 using the in-system programming. . . . . . . . . 19 7.2.6 using the serial number . . . . . . . . . . . . . . . . . 23 7.2.7 in-application programming method . . . . . . . 23 7.3 timers/counters 0 and 1 . . . . . . . . . . . . . . . . . 25 7.3.1 mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 7.3.2 mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7.3.3 mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7.3.4 mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.4 timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 7.4.1 capture mode . . . . . . . . . . . . . . . . . . . . . . . . . 30 7.4.2 auto-reload mode (up or down counter) . . . . . 31 7.4.3 programmable clock-out . . . . . . . . . . . . . . . . . 32 7.4.4 baud rate generator mode . . . . . . . . . . . . . . . 33 7.4.5 summary of baud rate equations . . . . . . . . . . 34 7.5 uarts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7.5.1 mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7.5.2 mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7.5.3 mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7.5.4 mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 7.5.5 framing error . . . . . . . . . . . . . . . . . . . . . . . . . 36 7.5.6 more about uart mode 1 . . . . . . . . . . . . . . . 36 7.5.7 more about uart modes 2 and 3 . . . . . . . . . 37 7.5.8 multiprocessor communications . . . . . . . . . . . 37 7.5.9 automatic address recognition . . . . . . . . . . . . 38 7.6 serial peripheral interface. . . . . . . . . . . . . . . . 39 7.6.1 spi features . . . . . . . . . . . . . . . . . . . . . . . . . . 39 7.6.2 spi description . . . . . . . . . . . . . . . . . . . . . . . . 40 7.7 watchdog timer. . . . . . . . . . . . . . . . . . . . . . . . 42 7.8 programmable counter array (pca) . . . . . . . 43 7.8.1 pca capture mode. . . . . . . . . . . . . . . . . . . . . 47 7.8.2 16-bit software timer mode. . . . . . . . . . . . . . . 48 7.8.3 high speed output mode . . . . . . . . . . . . . . . . 49 7.8.4 pulse width modulator mode . . . . . . . . . . . . . 50 7.8.5 pca watchdog timer . . . . . . . . . . . . . . . . . . . 50 7.9 security bit . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 7.10 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 7.10.1 power-on reset . . . . . . . . . . . . . . . . . . . . . . . 52 7.10.2 software reset . . . . . . . . . . . . . . . . . . . . . . . . 53 7.10.3 brown-out detection reset . . . . . . . . . . . . . . . 53 7.10.4 interrupt priority and polling sequence . . . . . . 53 7.11 power-saving modes . . . . . . . . . . . . . . . . . . . 56 7.11.1 idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 7.11.2 power-down mode . . . . . . . . . . . . . . . . . . . . . 57 7.12 system clock and clock options . . . . . . . . . . . 58 7.12.1 clock input options and recommended capacitor values for oscillator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 7.12.2 clock doubling option . . . . . . . . . . . . . . . . . . . 59 8 limiting values . . . . . . . . . . . . . . . . . . . . . . . . 60 9 recommended operating conditions . . . . . . 60 10 static characteristics . . . . . . . . . . . . . . . . . . . 62 11 dynamic characteristics . . . . . . . . . . . . . . . . . 64 11.1 explanation of symbols . . . . . . . . . . . . . . . . . 65 12 package outline . . . . . . . . . . . . . . . . . . . . . . . . 70 13 revision history . . . . . . . . . . . . . . . . . . . . . . . 73 14 data sheet status. . . . . . . . . . . . . . . . . . . . . . . 74 15 de?nitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 16 disclaimers . . . . . . . . . . . . . . . . . . . . . . . . . . . 74


▲Up To Search▲   

 
Price & Availability of P89V51RD2BN

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X